leeoniya / uPlot

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

implement disp.y in pathBuilders #634

Open leeoniya opened 2 years ago

leeoniya commented 2 years ago

currently stacked [1] and shifted [2] demos have to pre-stack the raw data, which means u.data no longer contains raw values and hooks/plugins cannot read this back for display and we also have to jump through a few hoops to get the live legend to display what we want.

uPlot's current way to tweak individual datapoints for rendering is by using a user-provided disp option to the pathbuilder of choice. this then handles adapting the raw values to ones needed for actual drawing. however, currently only the bars pathbuilder supports disp*, and it only supports adjusting x0 and size, but not y, which can be used to avoid pre-processing raw data before setData() calls.

* also the scatter demo's pathbuilder

[1] https://leeoniya.github.io/uPlot/demos/stacked-series.html [2] https://leeoniya.github.io/uPlot/demos/y-shifted-series.html

leeoniya commented 2 years ago

one significant hurdle with doing this is that scales must be computed before the paths are built, so it becomes impossible to properly determine scales without stacking occurring earlier. :thinking:

leeoniya commented 2 years ago

this could also allow for native support of floating bars or rects, which currently requires a custom pathBuilder.