✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

What am I doing wrong? (different plots using dropdown)

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([ 
        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")
    return fig


Hi @lcs_at welcome to the community.

Try print(df_filt.listeners_lastfm) and print(df_filt.artist) right before the fig =

See what you get.

Hi @adamschroeder, thank you.
Here it is:

that’s weird. When you choose a different value than United States, you still get an empty graph?

Well, i don’t know why, but its now working.
I’m very sorry for messing up , i don’t know what happened, but it wasn’t working before.
Thanks for your help!