From: Nico-DF Date: Mon, 12 Apr 2021 13:08:39 +0000 (+0200) Subject: Setting correct decimated values when below threshold (#8883) X-Git-Tag: v3.1.1~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a27de32dad961b52ef531ebf2928506dc58653e;p=thirdparty%2FChart.js.git Setting correct decimated values when below threshold (#8883) * Setting correct decimated values when below threshold * Using existing function for cleaning decimated data * Cleaning decimated only on current dataset * Reordering decimation clean to avoid allocation --- diff --git a/src/plugins/plugin.decimation.js b/src/plugins/plugin.decimation.js index f9bada37d..4f1db3661 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; }