]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Allow individual chart controllers to opt-in to the decimation plugin (#10182)
authorEvert Timberg <evert.timberg@gmail.com>
Mon, 21 Feb 2022 13:33:33 +0000 (08:33 -0500)
committerGitHub <noreply@github.com>
Mon, 21 Feb 2022 13:33:33 +0000 (08:33 -0500)
* Allow individual chart controllers to opt-in to the decimation plugin

* Code review feedback

src/controllers/controller.line.js
src/core/core.datasetController.js
src/plugins/plugin.decimation.js
types/index.esm.d.ts

index a62d9be895a1e598bce7e1aa18e9595378045df3..be96e72ed793fb94c9bb27fab106e2f420e47327 100644 (file)
@@ -7,6 +7,7 @@ export default class LineController extends DatasetController {
 
   initialize() {
     this.enableOptionSharing = true;
+    this.supportsDecimation = true;
     super.initialize();
   }
 
index b6c6778d999017f73acf03ceddb6ef8b3123f301..85cc50e91627110085e5a8523e0dc9729a92de43 100644 (file)
@@ -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 = [];
 
index 20fbb44b93ad574714a594b1e56db9e4ed29e7a1..95604e42966b4a863d9fa0199b20225167fc79f3 100644 (file)
@@ -217,7 +217,7 @@ export default {
         return;
       }
 
-      if (meta.type !== 'line') {
+      if (!meta.controller.supportsDecimation) {
         // Only line datasets are supported
         return;
       }
index ace3a249f7ca5bcf6082f001f7f83f5452ba0baf..882a8df47da198f85ba9542770421fbba0cff21f 100644 (file)
@@ -578,6 +578,10 @@ export class DatasetController<
   readonly index: number;
   readonly _cachedMeta: ChartMeta<TElement, TDatasetElement, TType>;
   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[];