tradingview / lightweight-charts

Performant financial charts built with HTML5 canvas
https://www.tradingview.com/lightweight-charts/
Apache License 2.0
9.23k stars 1.59k forks source link

Pop time series data #1518

Open tpunt opened 7 months ago

tpunt commented 7 months ago

Is your feature request related to a problem? Please describe.

I have implemented bar replay mode in my personal app. This is for things such as analysing price data as well as looking back at my past trades. Today, I don't believe there is a nice way to revert the latest bar(s). I have to perform a setData() operation on the time series, which resets the axes. This is the biggest pain point in the UX, since you often do not want the candles to be snapped back the right-hand side of the chart (especially with line titles enabled).

I have created a PoC here: https://github.com/tpunt/lightweight-charts/tree/bar-pop

Describe the solution you'd like

I'd like to be able to simply remove bars from the end of the time series. This will provide a smooth UX when in replay mode.

Additional context

This is a demo of what I mean:

https://github.com/tradingview/lightweight-charts/assets/1403064/f039d4b1-0a3b-448c-94f0-948ff8d5a04f

tpunt commented 7 months ago

I've managed to update my private fork to the latest version and integrate the time series popping ability. The above now looks like the following:

https://github.com/tradingview/lightweight-charts/assets/1403064/40fb4cc6-73d0-4fcc-a505-816fb803f539

It is almost exactly what I want. When popping a candlestick, the chart does jump 1 bar to the right still, but this is good enough for now.

I hope this better demonstrates the usefulness of this feature.

SlicedSilver commented 4 months ago

Thanks @tpunt, we will have a more detailed look into this during our work for the next major release of the library.