Adding click event to the blank space of the plot

So, I have this 2D line/scatter plot. Now what I want to do is that, when I click on a blank space of the plot i.e. where no point lies, I should get the nearest point location. So, I click on a blank space , I get the location of the click and then I calculate the distance of each points, and find the nearest of them. Is it possible to do?

Sounds like you’re looking for something like we’re planning on adding in https://github.com/plotly/plotly.js/issues/2696

In the meantime, you could try tweaking hoverdistance for example in https://codepen.io/etpinard/pen/exVdRX