leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars
MIT License
8.48k stars 370 forks source link

hooks.setSeries #895

Closed dingjunweibjkanyun closed 4 months ago

dingjunweibjkanyun commented 5 months ago

If I have a mixed graph of columns and lines.I only want the lines to trigger hooks.setSeries when the mouse moves in the drawing area.Is there any way? image

leeoniya commented 5 months ago

not currently.

i wonder if this should be done similarly to the cursor.dataIdx api that lets you return null to short-circuit the focus. something like opts.cursor.focus.seriesIdx = (u, seriesIdx) => seriesIdx | null.

https://github.com/leeoniya/uPlot/blob/378faf6fab9b84d86fd25a5b4425dc44d486b64d/demos/stack.js#L49

dingjunweibjkanyun commented 5 months ago

I understand. Thank you.

leeoniya commented 4 months ago

i think this should work for you: https://github.com/leeoniya/uPlot/commit/e5a9747585a8255269ce4a558c59e86db6fd761d

it exposes uPlot's internal y-distance measuring fn so you can customize it to return a custom distance that's bigger than focus.prox for whatever series you need, which will prevent focus.

https://github.com/leeoniya/uPlot/blob/e5a9747585a8255269ce4a558c59e86db6fd761d/demos/focus-cursor.html#L59-L66

turns out we needed this fn exposed in Grafana to give us control over the setSeries hook with custom pathBuilders, e.g. where the values represent a color scale and not cartesian y coordinates.