How to get the closest point that's been clicked, when hovermode is x/y and isn't 'closest'

Example: https://codepen.io/anon/pen/zeExWZ

I want hovermode to be ‘x’, but then if you click on the graph, I want to show an annotation for the point you clicked on. This code is “dummy” code, so I’m just manually selecting data.points[0] (as is shown in the annotations example), but they’re using ‘closest’ hovermode, so don’t run into this issue.

How can I figure out the closest point to the click?

1 Like