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

Decimation won't work when passing my own array. #9347

Closed
StefanNedelchev opened this issue Jul 3, 2021 · 7 comments
Closed

Decimation won't work when passing my own array. #9347

StefanNedelchev opened this issue Jul 3, 2021 · 7 comments

Comments

@StefanNedelchev
Copy link

I've been having issues trying to get decimation to work and for a long time and I thought that my config was wrong. At some point I decided to take a look at the docs again and set all necessary options as described in the requirements, and also providing a prepared data with parsing set to false. I still couldn't get decimation to work.

I tried to make a very basic chart implementation in a simple HTML file in order to eliminate the possibility that something in my app is causing the trouble and I still get the same result. Today I tried the exact same example file but instead of using my test dataset, I copied the code from the official decimation example which dynamically generates the dataset from a single timestamp. Surprisingly for me - it worked. If I use the code from the example, decimation works, but as soon as I pass my own data array - it doesn't work.

For more information - I use a linear time scale with timestamps for the x axis. I use the date-fns adapter and for a long time I have been thinking that my problem was either in the date adapter or the zoom plugin. But as it turned out - both plugins are fine and don't break decimation at all.

So my question is - what is going on? My suspicion is in the last requirement for decimation - The dataset object must be mutable. If that's the case, can someone explain what I'm doing wrong? I thought that objects and arrays in JavaScript are mutable, even if they are defined as constants. I tried using let and var but the result was still the same.

@kurkle
Copy link
Member

kurkle commented Jul 3, 2021

How many points does your dataset have and what is the chart width?

@StefanNedelchev
Copy link
Author

StefanNedelchev commented Jul 3, 2021

How many points does your dataset have and what is the chart width?

My mocked dataset has a 1000 points but the width of the chart is responsive. However, decimation doesn't seem to occur on any window size.

EDIT: Alright, I tried reducing the window size of the window even more and I noticed decimation happening below 249px (it was configured as follows: lttb decimation with 50 smaples)

@kurkle
Copy link
Member

kurkle commented Jul 3, 2021

You need points 4 times the width for it to decimate.

@kurkle
Copy link
Member

kurkle commented Jul 3, 2021

#9327 will allow configuring that

@StefanNedelchev
Copy link
Author

You need points 4 times the width for it to decimate.

What about cases where I have multiple datasets on the same x axis? If I have total points of let's say 4000 but they are distributed in 20 smaller datasets (in a similar way as displayed in the screenshot). Is decimation calculated per dataset or for the entire axis?
image

@kurkle
Copy link
Member

kurkle commented Jul 3, 2021

per dataset

@StefanNedelchev
Copy link
Author

Alright, so having in mind that in my case I don't have enough points for decimation and #9327 will allow us to chose a specific treshold, I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants