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=[
dcc.Dropdown(
id = 'selected_genre',
options=[
{'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',
multi=False,
style={'width': '95%'})
])
@app.callback(
[Output('first_graph', 'figure')],
[Input('selected_genre', 'value')]
)
def update_graph(option_genre):
print(option_genre)
print(type(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:
Figure({
'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