Skip to content

Conversation

@Nico-DF
Copy link
Contributor

@Nico-DF Nico-DF commented Jun 29, 2021

Improvement proposition

Adding a new option in the decimation plugin to change the threshold used to detect if the decimation must be applied

Reason

Currently, to check if the decimation plugin must be called, Chart.js will check the number of point to display and decide to not do anything if the number of points is below 4*canvasWidth.

While in most of cases it is enough, in some cases I find that this threshold is a bit too high
image

In this case, the number of points is 1183 per dataset and the width is 800px hence the decimation is not called.
There might be other solutions than introducing this variable (such as modifying the scale, editing graph display, etc.) but I think it would be quite useful and is retro-compatible as it will fallback to the old 4*width.

image

options.plugins.decimation = {
    algorithm: 'lttb',
    enabled: true,
    samples: 200,
    threshold: 100
}

@etimberg etimberg added this to the Version 3.5.0 milestone Jun 29, 2021
@etimberg
Copy link
Member

Approved, but will hold off merging until a 3.4.1 goes out the door. We've got one bug fixed queued up there already

@etimberg etimberg merged commit b4dee55 into chartjs:master Jul 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants