I’ve tried to modify the example of generating a scatter from a callback found here: https://dash.plot.ly/getting-started-part-2
I keep getting this exception raised.
dash.exceptions.InvalidCallbackReturnValue: The callback …graph-peer-universe.figure… is a multi-output.
Expected the output type to be a list or tuple but got {‘data’: [Scatter({
‘marker’: {‘line’: {‘color’: ‘white’, ‘width’: 0.5}, ‘size’: 15},
‘mode’: ‘markers’,
‘name’: ‘Corporate’,
‘opacity’: 0.7,
‘text’: array([‘Goldman Sachs & JBWere Superannuation - MySuper’,
‘QANTAS Super Gateway MySuper - Glidepath Take-Off’,
‘Telstra Super - MySuper Growth’], dtype=object),
‘x’: array([0.09322128, 0.07920195, 0.06869553]),
‘y’: array([750., 552., 638.])
})], ‘layout’: Layout({
‘hovermode’: ‘closest’, ‘legend’: {‘x’: 0, ‘y’: 1}
})}.
I’m very confident but just cant figure out whats wrong.
My function for the callback:
def graph_peer_universe(data, hidden, fund_types, asset_class, investment_name, fund_access, strategy, xaxis, yaxis, color):
data = return_table(data, hidden, fund_types, asset_class, investment_name, fund_access, strategy, convert_to_dict=False)
traces = []
for i in data[color].unique():
df_by_color = data[data[color] == i]
traces.append(go.Scatter(
x=df_by_color[xaxis],
y=df_by_color[yaxis],
text=df_by_color['investment_name'],
mode='markers',
opacity=0.7,
marker={
'size': 15,
'line': {'width': 0.5, 'color': 'white'}
},
name=i
))
return {
'data': traces,
'layout': go.Layout(
legend={'x': 0, 'y': 1},
hovermode='closest'
)
}
My callback
@app.callback([Output('graph-peer-universe', 'figure')],
[Input('hidden-data-radio', "value"),
Input('fund-types-dropdown', 'value'),
Input('asset-class-dropdown', 'value'),
Input('name-search', 'value'),
Input('fund-access-checklist', 'value'),
Input('strategy-checklist', 'value'),
Input('x-axis-dropdown', 'value'),
Input('y-axis-dropdown', 'value'),
Input('color-dropdown', 'value'),
])
def return_size_table(hidden, fund_types, asset_class, investment_name, fund_access, strategy, x_axis, y_axis, color):
return graph_peer_universe(df, hidden, fund_types, asset_class, investment_name, fund_access, strategy, x_axis, y_axis, color)
app.py
dcc.Graph(id="graph-peer-universe")