tradingview / lightweight-charts

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

Custom priceFormatter causes line to disappear when no data variance #1650

Open Fyko opened 1 month ago

Fyko commented 1 month ago

Lightweight Charts™ Version: 4.1.7

Issue When using a custom priceFormatter to create a text display for very large numbers, when all the current data for the chart is the same, no area/line is shown.

Sample code:

Video

https://github.com/user-attachments/assets/4dcbee08-3e9b-4bd6-ab4c-5d9914dbc387

Live example https://eidash.fyko.net/users/user_2fNmJ8ExsOPfUa4yqme7p26xtvN. Click the account selector, then click AlsoMajCartef. Observe the Eggs of Prophecy showing a straight line with no change, and Earning Bonus will show nothing, because there is no variance in data.

SlicedSilver commented 1 month ago

I tried to reproduce this with a simple example, and it seems that the issue only occurs with numbers around 1 quadrillion in size.

https://stackblitz.com/edit/lwc-1650?file=src%2Fmain.ts

I would suggest reducing the size of the number before providing it to the library (via setData).

Fyko commented 1 month ago

I'm glad to see you've been able to reproduce! Unfortunately, I can't reduce the size of my data