✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

InvalidCallbackReturnValue, another type of output is expected

Hi there! I’m trying to create my dashboard with graphs but get strange errors that I don’t know how to fix.
There’s my code:

app = dash.Dash(__name__, external_stylesheets)

df = pd.read_csv(r'C:\Users\473491\Downloads\games.csv')
df = df[df.Year_of_Release > 2000].dropna(axis=0)

app.layout = html.Div(children=[
            id = 'selected_genre',
                {'label': 'Sports', 'value': 'Sports'},
                {'label': 'Platform', 'value': 'Platform'},
                {'label': 'Racing', 'value': 'Racing'},
                {'label': 'Role-playing', 'value': 'Role-playing'},
                {'label': 'Puzzle', 'value': 'Puzzle'},
                {'label': 'Misc', 'value': 'Misc'},
                {'label': 'Shooter', 'value': 'Shooter'},
                {'label': 'Simulaion', 'value': 'Simulation'},
                {'label': 'Action', 'value': 'Action'},
                {'label': 'Fighting', 'value': 'Fighting'},
                {'label': 'Adventute', 'value': 'Adventure'},
                {'label': 'Strategy', 'value': 'Strategy'}],
            placeholder='Select a genre',
            style={'width': '95%'})

    [Output('first_graph', 'figure')],
    [Input('selected_genre', 'value')]
def update_graph(option_genre):

    df_fig = df[df.Genre == option_genre]

    fig = px.area(
        df_fig, x='Year_of_Release', y='Platform', line_group='Genre'

When I run this code I immediately get next message:

dash.exceptions.InvalidCallbackReturnValue: The callback ..first_graph.figure.. is a multi-output.
Expected the output type to be a list or tuple but got:
    'data': [],
    'layout': {'legend': {'tracegroupgap': 0},
               'margin': {'t': 60},
               'template': '...',
               'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'Year_of_Release'}},
               'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'Platform'}}}

What doest it mean? I don’t understand anything :frowning:

Hi @parusmajor

I can’t see the dcc.Graph in your layout (“first_graph”). :thinking:

Oh, I forgot to copy it. It’s in my script. And now it doesn’t matter because I’ve already found solution.
The problem was there:

    [Output('first_graph', 'figure')],
    [Input('selected_genre', 'value')]

Square brackets are not needed.