Is more than one duplicate callback allowed when using this feature?
In the example below, I have three callbacks with the same Output (i.e., two of which are duplicate callbacks). Only one of the duplicate callback seem to work.
Is this a limitation of duplicate callbacks as implemented below? Is there an alternative for allowing more than one duplicate callback? (e.g., Dash Extension MultiplexerTransform?)
Thanks in advance!
from dash import Dash, html, dcc, Input, Output, Patch, callback
import plotly.express as px
import plotly.graph_objects as go
import datetime
import random
app = Dash(__name__)
app.layout = html.Div([
html.Button('Draw Graph', id='draw-2'),
html.Button('Reset Graph', id='reset-2'),
html.Button('Update Graph', id='btn3'),
dcc.Graph(id='duplicate-output-graph')
])
@callback(
Output('duplicate-output-graph', 'figure', allow_duplicate=True),
Input('draw-2', 'n_clicks'),
prevent_initial_call=True
)
def draw_graph(n_clicks):
df = px.data.iris()
return px.scatter(df, x=df.columns[0], y=df.columns[1])
@callback(
Output('duplicate-output-graph', 'figure'),
Input('reset-2', 'n_clicks'),
)
def reset_graph(input):
return go.Figure()
if __name__ == '__main__':
app.run(debug=True)
@callback(
Output('duplicate-output-graph', 'figure', allow_duplicate=True),
Input('btn3', 'n_clicks'),
prevent_initial_call=True
)
def update_graph(input):
current_time = datetime.datetime.now()
random_value = random.randrange(1, 30, 1)
patched_figure = Patch()
patched_figure["data"][0]["x"].append(current_time)
patched_figure["data"][0]["y"].append(random_value)
return patched_figure
if __name__ == '__main__':
app.run(debug=True)