uPlot icon indicating copy to clipboard operation
uPlot copied to clipboard

Attach metadata to data point

Open yumochi opened this issue 1 year ago • 1 comments

Hi,

Bit new to uPlot. I am using a react version of uPlot, and I am wondering what is the best way to display additional metadata to my data point on hover with cursor?

To be more specific, we already display a value for every series on hover over the data point, but can we render additional meta data for that point as well?

yumochi avatar Oct 19 '24 01:10 yumochi

sure, you can use series.values option to return an object of properties to display in a table-style legend.

examples:

https://leeoniya.github.io/uPlot/demos/scatter.html https://github.com/leeoniya/uPlot/blob/f98d1d34d92a128f18fbaac9293910eed85ea19c/demos/scatter.html#L416-L435

https://leeoniya.github.io/uPlot/demos/time-periods.html https://github.com/leeoniya/uPlot/blob/f98d1d34d92a128f18fbaac9293910eed85ea19c/demos/time-periods.html#L128-L139

you can hold these values as additional data arrays that are not defined in the options.series array, and access them from there.

leeoniya avatar Oct 19 '24 01:10 leeoniya

Thank you for that. The data arrays idea is exactly what I had in mind too. Thank you for confirming it.

yumochi avatar Oct 21 '24 17:10 yumochi