Returning specific *data* element with plotly_click function

Hi all,

for sure this question is trivial for many of you, but I totally lack in js coding.

I have a simple scatter plot and I pass, besides x and y also an ids list that contains ids of each feature. Warning this ids are different than the standard id returned by plotly.

What I’m not able to do is getting the specific element of the ids list when clicked on the corresponding point in the plot.

The plot code is here:

hovering on the points return the value, an additional text and the corresponding ids.

Is it possible to get that value?

Many thanks for any hint



Here are all the fields you can grab from the plotly click event data.

Hi Etienne,

thanks again for the answer.
My problem is that I’m not able to get the single data of the clicked point. It is easy with x, y, id, pointNumber. But with something like this:

plotly_div.on('plotly_click', function(data){

I get the whole list of ids and not just the single item…

Maybe that’s more a pure js question that a plotly one…

Thanks again

what about this

plotly_div.on('plotly_click', function(data){


that’s exactly what you suggested me here:

the problem is that sometimes (I did not figure out when and why this happens, I think might be input data related) the id returned by plotly (what you wrote above) is not the same of the original id of the data.

So I was thinking that passing a default array with custom ids (different than standard ones) might be the solution