From d3a9bf375c6c99cea7c99273911ece8adfd9f655 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 21 Feb 2022 08:33:33 -0500 Subject: [PATCH] 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 --- src/controllers/controller.line.js | 1 + src/core/core.datasetController.js | 1 + src/plugins/plugin.decimation.js | 2 +- types/index.esm.d.ts | 4 ++++ 4 files changed, 7 insertions(+), 1 deletion(-) 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[]; -- 2.47.2