leeoniya / uPlot

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

Is it possible to modify labels values? #1016

Closed CheapGamma closed 3 weeks ago

CheapGamma commented 3 weeks ago

Hello! I'm still on track and step to step learn uPlot!

I have a question, is it possible to modify legends values?

For instance, on the image, if value will be 4 000 000 instead of 40, and I wish to modify it with my script, how can I do that?

Снимок экрана 2024-11-01 174619

leeoniya commented 3 weeks ago

yes, you can provide your own formatting callback using series.value option

leeoniya commented 3 weeks ago

you can see here:

https://github.com/leeoniya/uPlot/blob/f98d1d34d92a128f18fbaac9293910eed85ea19c/bench/uPlot.html#L99

CheapGamma commented 3 weeks ago

you can see here:

https://github.com/leeoniya/uPlot/blob/f98d1d34d92a128f18fbaac9293910eed85ea19c/bench/uPlot.html#L99

yeah, thank you very much!

{ label: 'Label', stroke: themeStyle.lineRed, fill: themeStyle.areaRed, width: 1, points: { show: false }, //dash: [10, 5], value: (u, value) => helpers_js.formatCash(value), }, it's worked!