Hello, i am new to dash and i was wondering if i could create 3 dropdown menus, and if u select a category in the first dropdown, it will affect the available options in the second dropdown and so on.
I have problem connecting the callbacks properly.
After that, i want to visualize the date (on y axis) and the sum of a 4th column (on x axis). Note that the 4th column isnt used in the 3 dropdowns above. Is that possible?
Below is the code that creates the 3 dropdowns (lines, route_name, departure_time), and i want to visualize the sum of events for each departure time, of a single route_name of a line
Blockquote
app.layout = html.Div([
dcc.Dropdown(
id=‘lines’,
options=[{‘label’: k, ‘value’: k} for k in df[‘lines’].unique()],
value=‘01’
),
html.Hr(),
dcc.Dropdown(
id='Route_name',
options = [{'label': k, 'value': k} for k in df['Route_name'].unique()],
value = 'sal'
),
dcc.Dropdown(
id='departure_time',
options = [{'label': k, 'value': k} for k in df['departure_time'].unique()],
value = '06:20'
),
html.Hr(),
html.Div(id='display-selected-values')
])
@app.callback(
Output(‘Route_name’, ‘options’),
Input(‘lines’, ‘value’))
def set_onoma_diadromis_options(selected_line):
return [{‘label’: i, ‘value’: i} for i in d2[selected_line]]
@app.callback(
Output(‘Route_name’, ‘value’),
Input(‘Route_name’, ‘options’))
def set_grammi_value(available_options):
return available_options[0][‘value’]
@app.callback(
Output(‘display-selected-values’, ‘children’),
Input(‘departure_time’, ‘value’),
Input(‘lines’, ‘value’),
Input(‘Route_name’, ‘value’))
def set_display_children(selected_line, selected_route_name):
return u’{} is a city in {}’.format(
selected_route_name, selected_line,
)
if name == ‘main’:
app.run_server(debug=True)
Blockquote