diff --git a/src/plugins/plugin.decimation.js b/src/plugins/plugin.decimation.js index f9bada37d24..4f1db3661bd 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); }); } @@ -232,6 +236,7 @@ export default { let {start, count} = getStartAndCountOfVisiblePointsSimplified(meta, data); if (count <= 4 * availableWidth) { // No decimation is required until we are above this threshold + cleanDecimatedDataset(dataset); return; }