I’m trying to build a dash that can update the figure with different values that can be select with a select box. But when i run the server i get an empty graph.
app.layout = html.Div([
dcc.Dropdown(
id = 'dropdown',
options = [
{'label':'United States', 'value':'United States'},
{'label':'United Kingdom', 'value':'United Kingdom'},
{'label':'Germany', 'value':'Germany'},
{'label':'Japan', 'value':'Japan'},
{'label':'France', 'value':'France'},
],
value = 'United States'
),
dcc.Graph(id = 'graph')
])
@app.callback(Output('graph', 'figure'), [Input('dropdown', 'value')])
def update_figure(selected_country):
df_filt = df[df.country == selected_country]
fig = px.bar(df_filt, x = 'artist', y = 'listeners_lastfm', hover_name="artist")
fig.update_layout(transition_duration=500)
return fig
data: