I created two buttons and two graphs with a different ID. But when I created a callback function as below.
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
app = dash.Dash()
app.layout = html.Div([
html.Button('Prev', **id='button-pgw1'**,n_clicks=0),
dcc.Graph(
**id='scatter1'**,
figure={
}
),
html.Button('Prev', **id='button-pgw2'**,n_clicks=0),
dcc.Graph(
**id='scatter2'**,
figure={
}
)
])
@app.callback(
dash.dependencies.Output(**'scatter1**', 'figure'),
[dash.dependencies.Input('button-pgw1', 'n_clicks')])
def update_output(n_clicks):
data = " button-pgw1 clicked"
return data
@app.callback(
dash.dependencies.Output('**scatter2'**, 'figure'),
[dash.dependencies.Input('button-pgw2', 'n_clicks')])
def update_output(n_clicks):
data = " button-pgw2 clicked"
return data
Here both the callback has a different id but when I am running this it’s showing error as below.
**CantHaveMultipleOutputs: **
You have already assigned a callback to the output
with ID “scatter1” and property “figure”. An output can only have
a single callback function. Try combining your inputs and
callback functions together into one function.