From 5b3f260d02b01ff4fc103809006cb33568989472 Mon Sep 17 00:00:00 2001 From: Nico-DF Date: Mon, 12 Apr 2021 10:15:15 +0200 Subject: [PATCH] Cleaning decimated only on current dataset --- src/plugins/plugin.decimation.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/plugin.decimation.js b/src/plugins/plugin.decimation.js index c359b2aac79..d5dce1a739d 100644 --- a/src/plugins/plugin.decimation.js +++ b/src/plugins/plugin.decimation.js @@ -153,14 +153,18 @@ function minMaxDecimation(data, start, count, availableWidth) { return decimated; } +function cleanDecimatedDataset(dataset) { + if (dataset._decimated) { + const data = dataset._data; + delete dataset._decimated; + delete dataset._data; + Object.defineProperty(dataset, 'data', {value: data}); + } +} + function cleanDecimatedData(chart) { chart.data.datasets.forEach((dataset) => { - if (dataset._decimated) { - const data = dataset._data; - delete dataset._decimated; - delete dataset._data; - Object.defineProperty(dataset, 'data', {value: data}); - } + cleanDecimatedDataset(dataset); }); } @@ -250,7 +254,7 @@ export default { let {start, count} = getStartAndCountOfVisiblePointsSimplified(meta, data); if (count <= 4 * availableWidth) { // No decimation is required until we are above this threshold - cleanDecimatedData(chart); + cleanDecimatedDataset(dataset); return; }