Hello I am very new to dash and I am trying to render a graph whose outpuut would depend on the two drop down selection on the layput I have written the below graph_update logic, however somehow it is not workig.
app.layout = html.Div([
html.Div([
html.H1('Stock Tickers'),
dcc.Dropdown(
id='my-dropdown',
options=[
{'label': 'A', 'value': 'A'},
{'label': 'B', 'value': 'B'},
{'label': 'C', 'value': 'C'}
],
value='A'
)
],
style={'width': '20%', 'display': 'inline-block'}
),
dcc.Dropdown(
id='my-dropdown1',
options=[
{'label': '250,000', 'value': '250000'},
{'label': '500,000', 'value': '500000'},
{'label': '750,000', 'value': '750000'},
{'label': '1,000,000', 'value': '1000000'}
],
value='250000'
),
dcc.Graph(id='my-graph')
], className="container")
@app.callback(Output('my-graph', 'figure'),
[Input('my-dropdown', 'value'), Input('my-dropdown1', 'value')])
def update_graph(selected_dropdown_value, selected_imp_value):
dff = df[(df['Demo'] == selected_dropdown_value) & (df['Imp_cap'] == selected_impresession_value)]
return {
'data': [{
'x': dff.Imp
'y': dff.user,
'line': {
'width': 3,
'shape': 'spline'
}
}],
'layout': {
'margin': {
'l': 30,
'r': 20,
'b': 30,
't': 20
}
}
}
I was hoping if someone can please help me to resolve the issue
Thanks a lot in advance !!
'x': dff.Imp, and you need to changeselected_impresession_valuetoselected_imp_value, because that's how you defined the parameter for the function. If you can edit your post to include an exampledf, I'll try to help more!