esnet / react-timeseries-charts

Declarative and modular timeseries charting components for React
http://software.es.net/react-timeseries-charts
Other
862 stars 284 forks source link

Highlighting closest line #318

Open AlanFoster opened 6 years ago

AlanFoster commented 6 years ago

Is it possible to highlight the closest line to the user's mouse position?

For instance like - http://dygraphs.com/gallery/#g/highlighted-series

I've been poking around the source code and documentation and I can see that it's easy to get the X position via onTrackerChanged and using series.AtTime(tracker), but from what I can tell there's no way to calculate the closest line based on its Y position? 🤔

pjm17971 commented 6 years ago

No, there's no support for closest line.

You can highlight the line under the cursor which if I remember correctly is actually a larger hit area than the line itself. That approach works for us, but we usually don't have so many lines as in your link.

Beyond that, as you say, you can manage this outside the library by using the tracker position (try onMouseMove to grab the x, y position and onTrackerChanged to give you the time) and then choosing whichever line you want based on that information.

I'll mark this item as an enhancement though, since it's a reasonable request.

AlanFoster commented 6 years ago

Thanks for the quick reply @pjm17971 :+1:

you can manage this outside the library by using the tracker position (try onMouseMove to grab the x, y position and onTrackerChanged to give you the time) and then choosing whichever line you want based on that information.

Is that currently possible without the yScale being exposed by this component? 🤔

pjm17971 commented 6 years ago

Yeah, you're right, that would be tricky. There's actually multiple scales associated with that area too, to make things more complicated. So perhaps there's no easy way to get the effect you want right now. I'll think about it a little more though.

AlanFoster commented 6 years ago

Awesome, any help would be appreciated! :+1: