Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow individual chart controllers to opt-in to the decimation plugin #10182

Merged
merged 2 commits into from Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
etimberg marked this conversation as resolved.
Show resolved Hide resolved
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;
etimberg marked this conversation as resolved.
Show resolved Hide resolved
}

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