Black Lives Matter. Please consider donating to Black Girls Code today.

Get markers of current selected zoom area

Hi Plotly community,

is there a way to get the index of all visible markers after zooming in to a graph.

This is my graph:

After I zoomed in, I see for example these points:

So the function should return the index oft the 3rd and 4th markers of the blue line and the 1st and the 2nd index of the orange line.

Any help would be very nice!

Thanks!!

Bump… Any ideas or help would be greate!

Okay, after doing some research. I found such function is not implemented jet:

I’v done it like so, quite sinple:

 myPlot.on('plotly_selected', function(eventData) {
console.log(eventData.points);//<---- all markers

//after that zoom in manually
Plotly.relayout('myDiv', 'xaxis.range', [+new Date(eventData.range.x[0]), +new Date(eventData.range.x[1])])
});

Hmm, dont like this solution though.
It’s too hacky and you can’t for example zoom back out, with the double click…

1 Like