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

Commit 1ee676a

Browse files
committed
add clear_on_doubleclick prop for clearing clickData
1 parent e133a33 commit 1ee676a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

dash_core_components/metadata.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,17 @@
920920
"computed": false
921921
}
922922
},
923+
"clear_on_doubleclick": {
924+
"type": {
925+
"name": "bool"
926+
},
927+
"required": false,
928+
"description": "If True, `clear_on_doubleclick` will clear the `clickData` property\nwhen the user double clicks (when dragmode='zoom').",
929+
"defaultValue": {
930+
"value": "false",
931+
"computed": false
932+
}
933+
},
923934
"hoverData": {
924935
"type": {
925936
"name": "object"

src/components/Graph.react.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default class PlotlyGraph extends Component {
102102
}
103103

104104
bindEvents() {
105-
const {id, fireEvent, setProps, clear_on_unhover} = this.props;
105+
const {id, fireEvent, setProps, clear_on_unhover, clear_on_doubleclick} = this.props;
106106

107107
const gd = document.getElementById(id);
108108

@@ -144,6 +144,13 @@ export default class PlotlyGraph extends Component {
144144
if (fireEvent) fireEvent({event: 'unhover'});
145145
}
146146
});
147+
gd.on('plotly_doubleclick', () => {
148+
if (clear_on_doubleclick) {
149+
if (setProps) setProps({clickData: null});
150+
if (fireEvent) fireEvent({event: 'doubleclick'});
151+
}
152+
})
153+
147154
}
148155

149156
componentDidMount() {
@@ -212,6 +219,12 @@ PlotlyGraph.propTypes = {
212219
*/
213220
clickData: PropTypes.object,
214221

222+
/**
223+
* If True, `clear_on_doubleclick` will clear the `clickData` property
224+
* when the user double clicks (when dragmode='zoom').
225+
*/
226+
clear_on_doubleclick: PropTypes.bool,
227+
215228
/**
216229
* Data from latest hover event
217230
*/
@@ -225,6 +238,7 @@ PlotlyGraph.propTypes = {
225238
*/
226239
clear_on_unhover: PropTypes.bool,
227240

241+
228242
/**
229243
* Data from latest select event
230244
*/
@@ -481,6 +495,7 @@ PlotlyGraph.defaultProps = {
481495
ease: 'cubic-in-out'
482496
}
483497
},
498+
clear_on_doubleclick: false,
484499
clear_on_unhover: false,
485500
config: {
486501
staticPlot: false,

0 commit comments

Comments
 (0)