leeoniya / uPlot

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

Seeking guidance on creating a dynamic chart with the following features #942

Open Hameed2000 opened 3 weeks ago

Hameed2000 commented 3 weeks ago

Hey, thanks for this amazing library.

I'm trying to create a chart with the following features all at once but am running into trouble.

Features: Dynamically updating chart that keeps old data Ability to zoom and pan The chart should have a scrolling effect that stops once the user isn't viewing live data but continues once live data is in range again

Hameed2000 commented 3 weeks ago

I'm able to pan and zoom and keep old data but I can't figure out how to do the scrolling effect when the user isn't viewing live data and continuing the scrolling effect once live data is in view again.

Also I run into an issue where points stop being drawn unless I am interacting with the chart through panning or zooming.

leeoniya commented 4 days ago

I can't figure out how to do the scrolling effect when the user isn't viewing live data and continuing the scrolling effect once live data is in view again.

you should call setData with false second arg to prevent it from setting the x scale to match the new data.

https://github.com/leeoniya/uPlot/blob/e579947241a48c401a7a2c96f1815f44fd19173a/dist/uPlot.d.ts#L73-L74