Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unbind Click Events in Plotly

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.

like image 504
dim_voly Avatar asked Nov 23 '25 11:11

dim_voly


1 Answers

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");
like image 180
SemmZemm Avatar answered Nov 25 '25 23:11

SemmZemm