Skip to content

Commit

Permalink
Allow individual chart controllers to opt-in to the decimation plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Feb 20, 2022
1 parent 2f7550d commit 876dc88
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/controllers/controller.line.js
Expand Up @@ -6,8 +6,9 @@ import {_lookupByKey} from '../helpers/helpers.collection';
export default class LineController extends DatasetController {

initialize() {
this.enableOptionSharing = true;
super.initialize();
this.enableOptionSharing = true;
this.supportsDecimation = true;
}

update(mode) {
Expand Down
1 change: 1 addition & 0 deletions src/core/core.datasetController.js
Expand Up @@ -249,6 +249,7 @@ export default class DatasetController {
this.linkScales();
meta._stacked = isStacked(meta.vScale, meta);
this.addElements();
this.supportsDecimation = false
}

updateIndex(datasetIndex) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plugin.decimation.js
Expand Up @@ -217,7 +217,7 @@ export default {
return;
}

if (meta.type !== 'line') {
if (!meta.controller.supportsDecimation) {
// Only line datasets are supported
return;
}
Expand Down
4 changes: 4 additions & 0 deletions types/index.esm.d.ts
Expand Up @@ -576,6 +576,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[];
Expand Down

0 comments on commit 876dc88

Please sign in to comment.