-
-
Notifications
You must be signed in to change notification settings - Fork 438
Description
Hi, and thanks for uPlot. I’m using it a lot and really appreciate its speed and small footprint.
I’m using uPlot in a case where multiple series share the same X values. With the current cursor behavior, when several points share the same X, the cursor snaps to the nearest X index as expected, but for each series the highlighted point at that X seems fixed: moving the mouse up and down over vertically stacked points does not change which point is highlighted.
For my use case it would be useful to have an optional behavior where:
- uPlot still finds the nearest X index as it does now, and
- for each visible series, among all points that share that X value, the point whose rendered Y (
valToPos(y, scale)) is closest to the cursor’s Y position is selected.
In short: “closest X, then per-series closest Y” when multiple points share the same X value.
I put together a small repro and an experimental cursor.dataIdx override here (two charts: default behavior vs. overridden behavior):
Questions:
- Is the current behavior for shared X values (sticking to a single index per series at that X, regardless of cursor Y) intentional?
- I’m wondering whether a “closest X, then per-series closest Y” hover mode might be something you’d consider supporting as an optional behavior in uPlot, or at least mentioning as a recommended pattern for shared-X use cases like this.
I’m mainly sharing this use case and the workaround in case it’s useful to you or other users. If this feels out of scope for core, I’m also totally fine keeping it as a user-level pattern like in the JSFiddle.