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 undefined in 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 undefined data while getting data from the series using seiesApi.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 undefined values in data. seriesApi.data() is returning only 90 data excluding 10 undefined data.

Expected behavior:

  • seriesApi.data() should return all actual data with undefined value if any. i.e. If I set 100 data in series with 10 undefined values then seriesApi.data() should return me 100 data with 10 undefined.

Source: tradingview/lightweight-charts