I have multiple dropdowns and output graphs where I need the default value to be All Items in the dropdown.
For that in options i added All as one of the options to the dropdown and tried to implement the code below.
@app.callback(
Output(‘example-graph-1’, ‘figure’),
[Input(‘country’, ‘value’),
Input(‘network-type’, ‘value’) ])
def update_age_graph(selected_country ,selected_network):
if selected_country == 'All':
country_list = list(pr_group['Nationality'].unique())
else:
country_list = country
for network in selected_network:
if network == 'All':
network_list = list(pr_group['NETWORK_TYPE'].unique())
else:
network_list = network
df = pr_group[pr_group['Nationality'].isin(country_list) & pr_group['NETWORK_TYPE'].isin(network_list)]
df = pd.DataFrame(df >> group_by(X.Age_band) >>
summarize(Premium = X.Premium_collected.sum()))
return {
'data': [ go.Bar(x = df['Age_band'], y = df['Premium'], name = 'Premium') ],
'layout': go.Layout(
title = 'Age Plot',
plot_bgcolor = colors['background'],
paper_bgcolor = colors['background'],
font = {
'color': colors['text'] })
}