Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add duplicate callback support #5

Open
wants to merge 4 commits into
base: async-dash
Choose a base branch
from

Conversation

brendanillies
Copy link

Dash utilizes the clean_property_name utility to remove the hash appended to duplicate component_property names via callbacks. Currently, repo does not support cleaning and thus duplicate callbacks are not registered correctly.

MWE

from async_dash import Dash
from dash import html, dcc, Output, Input
from quart import Quart

import plotly.express as px
import plotly.graph_objects as go

server = Quart(__name__)
app = Dash(
    server=server,
    prevent_initial_callbacks=True
)

app.layout = html.Div([
    html.Button('Draw Graph', id='draw-2'),
    html.Button('Reset Graph', id='reset-2'),
    dcc.Graph(id='duplicate-output-graph')
])

@app.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], color="species")

@app.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)

@brendanillies
Copy link
Author

Dash version needs to be bumped to >=2.9. Will review other dependencies as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant