This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Add n_clicks to annotationClickData so that callback is fired when clicking on an annotation multiple times#928
Closed
Add n_clicks to annotationClickData so that callback is fired when clicking on an annotation multiple times#928
Conversation
Collaborator
|
@chriddyp while we investigate a deeper fix, were you able to test out the proposed workaround using circular callbacks plotly/dash#1525 to reset |
Member
Author
|
This workaround does indeed work 👍🏼 import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import json
app = dash.Dash(__name__)
app.layout = html.Div([
dcc.Graph(id='graph', figure={
'data': [{'y': [2, 1, 5]}],
'layout': {
'annotations': [{
'text': 'click me',
'x': 0.5, 'y': 0.5, 'xref': 'paper', 'yref': 'paper',
'captureevents': True
}]
}
}),
html.Pre(id='output')
])
@app.callback(
Output('output', 'children'),
Output('graph', 'clickAnnotationData'),
Input('graph', 'clickAnnotationData'))
def update_output(c):
print(c)
return [json.dumps(c, indent=4), None]
app.run_server(debug=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Currently
dash' verifies that the old props != the new props before firing a callback.Line: https://github.com/plotly/dash/blame/dev/dash-renderer/src/TreeContainer.js#L126
Commit: plotly/dash@05908b2
This behavior prevents multiple clicks on the same annotation from firing the callback.
Dash's comparison may not be the right behavior, but this PR will at least get around the issue.