{"record":{"id":"64bd2a7bc5243478","repo":"chartjs/Chart.js","slug":"unsupported-decimation-algorithm-options-algori","errorCode":null,"errorMessage":"Unsupported decimation algorithm '${options.algorithm}'","messagePattern":"Unsupported decimation algorithm '(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/plugins/plugin.decimation.js","lineNumber":277,"sourceCode":"            return this._decimated;\n          },\n          set: function(d) {\n            this._data = d;\n          }\n        });\n      }\n\n      // Point the chart to the decimated data\n      let decimated;\n      switch (options.algorithm) {\n      case 'lttb':\n        decimated = lttbDecimation(data, start, count, availableWidth, options);\n        break;\n      case 'min-max':\n        decimated = minMaxDecimation(data, start, count, availableWidth);\n        break;\n      default:\n        throw new Error(`Unsupported decimation algorithm '${options.algorithm}'`);\n      }\n\n      dataset._decimated = decimated;\n    });\n  },\n\n  destroy(chart) {\n    cleanDecimatedData(chart);\n  }\n};\n","sourceCodeStart":259,"sourceCodeEnd":288,"githubUrl":"https://github.com/chartjs/Chart.js/blob/cb02e1d207bd4c4c40b20c259017f85f26f1e30a/src/plugins/plugin.decimation.js#L259-L288","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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)."],"exampleFix":"// before\nplugins: { decimation: { enabled: true, algorithm: 'minmax' } } // typo -> throws\n\n// after\nplugins: { decimation: { enabled: true, algorithm: 'min-max' } }","handlingStrategy":"validation","validationCode":"// Validate decimation config before passing it to Chart.js.\nconst SUPPORTED = new Set(['lttb', 'min-max']);\nfunction validateDecimation(options) {\n  const d = options?.plugins?.decimation;\n  if (d?.enabled) {\n    const algo = d.algorithm || 'min-max';\n    if (!SUPPORTED.has(algo)) {\n      throw new Error(`Unsupported decimation algorithm '${algo}'. Use 'lttb' or 'min-max'.`);\n    }\n    for (const ds of options.data?.datasets ?? []) {\n      const a = ds.decimation?.algorithm;\n      if (a && !SUPPORTED.has(a)) {\n        throw new Error(`Dataset decimation algorithm '${a}' is unsupported.`);\n      }\n    }\n  }\n}\nvalidateDecimation(config);","typeGuard":"// Constrain algorithm strings at the type level.\ntype DecimationAlgo = 'lttb' | 'min-max';\nfunction isDecimationAlgo(s) { return s === 'lttb' || s === 'min-max'; }","tryCatchPattern":null,"preventionTips":["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."],"tags":["decimation","plugin","configuration","data"],"backgroundTag":null,"analyzedSha":"cb02e1d207bd4c4c40b20c259017f85f26f1e30a","analyzedAt":"2026-08-12T23:38:10.965Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}