2

I am trying to build a bar chart using dash plotly and while the dropdown is getting selected, it is unable to refresh the page with the selected value from dropdown. I am new to Dash. Any help will be appreciated.The graph is ok with the defult value being selected (that is "FII' in this case), however the moment I select different value ( I have FII,DII,Pro,Total) values in Client_Type.

    df = df1[df1['Month'].isin([2,3])]
    app = dash.Dash()
    df = df1[df1['Month'].isin([2,3])]
    app = dash.Dash()
    party_data = []
    for client in df['Client_Type'].unique():
         party_data.append({'label': client, 'value': 'Client_Type'})


   app.layout = html.Div([
   dcc.Graph(id='graph'),
   dcc.Dropdown(id='client-picker',options=party_data,value= 'FII' )

])

  @app.callback(Output('graph', 'figure'),
          [Input('client-picker', 'value')])
def update_figure(abc):
df1 = df[df.Client_Type == abc]
print(df1.head())
date1 = df1['Date']
Fut_Index_Long1 = df1['Fut_Index_Long']

return {
    'data': [go.Bar(x=date1, y=Fut_Index_Long1)]
}

   if __name__ == '__main__':
app.run_server(debug=True)

1 Answer 1

1

I think the options of your Dropdown are configured wrongly. The label in the dict is the name of the value displayed in Dropdown. First I would try:

   for client in df['Client_Type'].unique():
             party_data.append({'label': client, 'value': client})

The label you can later format.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.