From: Evert Timberg Date: Mon, 21 Feb 2022 13:33:33 +0000 (-0500) Subject: Allow individual chart controllers to opt-in to the decimation plugin (#10182) X-Git-Tag: v3.8.0~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3a9bf375c6c99cea7c99273911ece8adfd9f655;p=thirdparty%2FChart.js.git Allow individual chart controllers to opt-in to the decimation plugin (#10182) * Allow individual chart controllers to opt-in to the decimation plugin * Code review feedback --- diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index a62d9be89..be96e72ed 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -7,6 +7,7 @@ export default class LineController extends DatasetController { initialize() { this.enableOptionSharing = true; + this.supportsDecimation = true; super.initialize(); } diff --git a/src/core/core.datasetController.js b/src/core/core.datasetController.js index b6c6778d9..85cc50e91 100644 --- a/src/core/core.datasetController.js +++ b/src/core/core.datasetController.js @@ -237,6 +237,7 @@ export default class DatasetController { this._drawStart = undefined; this._drawCount = undefined; this.enableOptionSharing = false; + this.supportsDecimation = false; this.$context = undefined; this._syncList = []; diff --git a/src/plugins/plugin.decimation.js b/src/plugins/plugin.decimation.js index 20fbb44b9..95604e429 100644 --- a/src/plugins/plugin.decimation.js +++ b/src/plugins/plugin.decimation.js @@ -217,7 +217,7 @@ export default { return; } - if (meta.type !== 'line') { + if (!meta.controller.supportsDecimation) { // Only line datasets are supported return; } diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index ace3a249f..882a8df47 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -578,6 +578,10 @@ export class DatasetController< readonly index: number; readonly _cachedMeta: ChartMeta; enableOptionSharing: boolean; + // If true, the controller supports the decimation + // plugin. Defaults to `false` for all controllers + // except the LineController + supportsDecimation: boolean; linkScales(): void; getAllParsedValues(scale: Scale): number[];