3

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.

0

2 Answers 2

4

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");
Sign up to request clarification or add additional context in comments.

Comments

3

I think this should work

Plotly.newPlot('myDiv', data, layout);

You can see added line in js part in Codepen.

Related GitHub issue

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.