Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Add n_clicks to annotationClickData so that callback is fired when clicking on an annotation multiple times #928

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/Graph.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ PlotlyGraph.propTypes = {

/**
* Data from latest click annotation event. Read-only.
* In order for an annotation to be "clickable", set
*`captureevents=True` within the annotation object.
*/
clickAnnotationData: PropTypes.object,

Expand Down
8 changes: 8 additions & 0 deletions src/fragments/Graph.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ class PlotlyGraph extends Component {
['event', 'fullAnnotation'],
eventData
);
if (this.props.clickAnnotationData) {
// Provide n_clicks so that multiple clicks on an annotation are triggered
clickAnnotationData.n_clicks = (
parseInt(this.props.clickAnnotationData.n_clicks, 10) + 1
);
} else {
clickAnnotationData.n_clicks = 1;
}
setProps({clickAnnotationData});
});
gd.on('plotly_hover', eventData => {
Expand Down