Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

series.data() does not return whitespace data #1649

Open
varunsavaliya opened this issue Jul 22, 2024 · 3 comments
Open

series.data() does not return whitespace data #1649

varunsavaliya opened this issue Jul 22, 2024 · 3 comments
Labels
bug Unexpected problem or unintended behavior. good first issue Good issue for first-time contributors.

Comments

@varunsavaliya
Copy link

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.
@edew edew changed the title series.data() method not returning the actual data series.data() does not return whitespace data Jul 22, 2024
@edew
Copy link
Contributor

edew commented Jul 22, 2024

Thanks for the detailed report @varunsavaliya

We will investigate how we can improve this.

@edew edew added bug Unexpected problem or unintended behavior. good first issue Good issue for first-time contributors. labels Jul 22, 2024
@edew
Copy link
Contributor

edew commented Jul 22, 2024

I believe this is happening because we filter whitespace data in these places.

this._seriesRowsBySeries.set(series, seriesRows.filter(isSeriesPlotRow));

export function isSeriesPlotRow(row: SeriesPlotRow | WhitespacePlotRow): row is SeriesPlotRow {

@varunsavaliya
Copy link
Author

varunsavaliya commented Jul 22, 2024

I found one temporary solution for this:
You can pass NaN instead of undefined. it will not filter the data as the function only filters if the value is undefined.

return (row as Partial<SeriesPlotRow>).value !== undefined;

Here we can do one thing, we can remove this undefined check. But, it may have some impact on other functionalities. Instead, we can pass a flag in series.data(someFlag) for including whitespace data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior. good first issue Good issue for first-time contributors.
Projects
None yet
Development

No branches or pull requests

2 participants