series.data() does not return whitespace data
Author: varunsavaliyaCreated Jul 22, 2024Updated Feb 9, 2026
Labelsbuggood first issue
Lightweight Charts™ Version:
Steps/code to reproduce:
- Add one chart with candlestick data and another chart with line series data.
- Add 100 data in both the series but here the catch is, the first 10 data's value is
undefinedin line series and candlestick data will be normal data. - Now try to get the data using
seriesApi.data()of line series and candlestick series. - You'll get 100 data in the candlestick series which is usual behavior but in the line series you'll only get 90 data, it's automatically removing
undefineddata while getting data from the series usingseiesApi.data(). - Now, the issue is, that it is creating a break in the syncing of 2 charts which I am attaching new 100 data in both series. i.e. old 100 data(from series) + new 100 data.
Here, assume that the below function is used for updating series data. I'll pass new data and it will add it before the existing data.
handleData = (series: ISeriesApi<SeriesType>, data: any) => {
series.setData([...data, ...series.data()])
}Actual behavior:
- I am setting 100 data in series with 10
undefinedvalues in data.seriesApi.data()is returning only 90 data excluding 10undefineddata.
Expected behavior:
seriesApi.data()should return all actual data withundefinedvalue if any. i.e. If I set 100 data in series with 10undefinedvalues thenseriesApi.data()should return me 100 data with 10undefined.
Source: tradingview/lightweight-charts