Adding threshold option to decimation plugin #9327
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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.