Answers for "dependent dropdowns dash"

0

dependent dropdowns dash

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
             }
         }
     }
Posted by: Guest on February-14-2020

Browse Popular Code Answers by Language