Reputation: 541
I can't seem to unbind the click event when using the plotly library, there doesn't seem to be a function for it. I need to select 4 points on a graph and then I don't need the handler anymore.
The example on the official site binds events but doesn't demonstrate a way to get rid of chart click handlers.
For now I'll be implementing a loop in the one handler and it will just ignore clicks beyond the 4 that I need. Doesn't seem efficient though.
Upvotes: 3
Views: 1941
Reputation: 51
As suggested in https://github.com/plotly/plotly.js/issues/107#issuecomment-279716312 you can use removeListener and removeAllListeners API methods:
graphDiv.removeListener("plotly_click", handler);
graphDiv.removeAllListeners("plotly_click");
Upvotes: 4