chartjs/Chart.js · error · Error
Unsupported decimation algorithm '${options.algorithm}'
Error message
Unsupported decimation algorithm '${options.algorithm}' What it means
The decimation plugin's beforeElementsUpdate iterates datasets; for each that exceeds the threshold it switches on options.algorithm. Only 'lttb' and 'min-max' are implemented; any other value (including undefined when the user enables decimation with a non-default algorithm, or a typo) falls through to default and throws. The default dataset algorithm is 'min-max' (plugin defaults), so this fires only when the user explicitly sets an unsupported value.
Source
Thrown at src/plugins/plugin.decimation.js:277
return this._decimated;
},
set: function(d) {
this._data = d;
}
});
}
// Point the chart to the decimated data
let decimated;
switch (options.algorithm) {
case 'lttb':
decimated = lttbDecimation(data, start, count, availableWidth, options);
break;
case 'min-max':
decimated = minMaxDecimation(data, start, count, availableWidth);
break;
default:
throw new Error(`Unsupported decimation algorithm '${options.algorithm}'`);
}
dataset._decimated = decimated;
});
},
destroy(chart) {
cleanDecimatedData(chart);
}
};
View on GitHub (pinned to cb02e1d207)
Solutions
- Use one of the two supported algorithms: 'lttb' or 'min-max'.
- If you need a different algorithm, disable the built-in plugin (plugins.decimation.enabled = false) and pre-decimate the data yourself before passing to Chart.js.
- Double-check spelling and casing: 'min-max' (hyphenated), 'lttb' (lowercase).
- Confirm the algorithm is set at the right scope (plugins.decimation.algorithm or dataset-level decimation.algorithm).
Example fix
// before
plugins: { decimation: { enabled: true, algorithm: 'minmax' } } // typo -> throws
// after
plugins: { decimation: { enabled: true, algorithm: 'min-max' } } Defensive patterns
Strategy: validation
Validate before calling
// Validate decimation config before passing it to Chart.js.
const SUPPORTED = new Set(['lttb', 'min-max']);
function validateDecimation(options) {
const d = options?.plugins?.decimation;
if (d?.enabled) {
const algo = d.algorithm || 'min-max';
if (!SUPPORTED.has(algo)) {
throw new Error(`Unsupported decimation algorithm '${algo}'. Use 'lttb' or 'min-max'.`);
}
for (const ds of options.data?.datasets ?? []) {
const a = ds.decimation?.algorithm;
if (a && !SUPPORTED.has(a)) {
throw new Error(`Dataset decimation algorithm '${a}' is unsupported.`);
}
}
}
}
validateDecimation(config); Type guard
// Constrain algorithm strings at the type level.
type DecimationAlgo = 'lttb' | 'min-max';
function isDecimationAlgo(s) { return s === 'lttb' || s === 'min-max'; } Prevention
- Spell algorithms exactly: 'lttb', 'min-max' (lowercase, hyphenated).
- Keep a constants module for supported algorithms and import from it.
- If you need a custom algorithm, pre-decimate the data and leave the plugin disabled.
- Add a config validator in shared charting wrappers.
When it happens
Trigger: Setting plugins.decimation.enabled = true together with plugins.decimation.algorithm = 'average' (or any non-'lttb'/'min-max' string, or a typo like 'minmax'); enabling decimation on a dataset and overriding algorithm per-dataset to an unsupported value.
Common situations: Assuming a decimation algorithm exists that does not (e.g. 'average', 'sample', 'pttb'); copy-pasting config from a tutorial for a different library; misreading docs and writing 'minmax' instead of 'min-max'.
Related errors
- class does not have id: ${item}
- ${min} and ${max} are too far apart with stepSize of ${stepS
- This method is not implemented: Check that a complete date a
- Cannot determine type of '${id}' axis. Please provide 'axis'
- "${id}" is not a registered ${type}.
AI-assisted analysis of chartjs/Chart.js@cb02e1d207 (2026-08-12).
Data as JSON: /api/errors/64bd2a7bc5243478.
Report an issue: GitHub.