Exception for callback while creating figure


I’m trying to create a figure for path of some entity (car, plane, etc…).

This is my code:

app.layout = html.Div([
    # auto update every 60 msec
    dcc.Interval(id='graph-update', interval=5000),
            html.H3("Path", style={'text-align': 'center'}),
            dcc.Graph(id='Path', figure={})],
            className="six columns"),  # see https://codepen.io/chriddyp/pen/bWLwgP

            html.H3("Bearing-Depression", style={'text-align': 'center'}),
            dcc.Graph(id='Bearing-Depression', figure={})],
            className="six columns"),

@ app.callback([Output('Path', 'figure'),
               [Input('graph-update', 'n_intervals')])
def draw_path(n):
     db_connectoin = sqlite3.connect(config.DB_LOCATION)
	df = pd.read_sql('Select Lat Long rom all data', db_connection)
	fig = px.scatter_mapbox(df, lat="Lat", lon="Long")
	fig.update_layout(mapbox_style = "white-bg",
									"below": 'traces',
									"sourcetype": 'raster'
									"source": ["{z}/{x}/{y}.png"],
	return fig

When there is a callback, I’m receiving an error as follows:

dash.exceptions.InvalidCallbackReturnValue: The callback …Path.figure… is a multi-output. Expected the output type to be a list or tuple but got Figure … Exception on /_dash-update-component [POST]

How to solve this issue?



The error is saying that your callback has more than one Output.
I think you have an error in this row:

@ app.callback([Output('Path', 'figure'),

Try deleting the [ or just adding an ] before the ,

This was copy error (I’m working on computer not connected to the web).

There is

@app.callback([Output (…)], [Input(…)],)
def draw_path(n):

OK, the issue seems to be that the callback statement shall be @app.callback(Output (…), [Input(…)],) rather than @app.callback(**[**Output (…)**]**, [Input(…)],)


I just link this answer from another thread. It might be useful for you in the future. :slight_smile:

The gist is: If you define your Output as a list, you should return back a list.