Chart.js Decimation Plugin: Choosing LTTB vs Min‑Max Algorithm
0 reputation · 23 Mar 2026, 20:45 UTC
0 reputation · 23 Mar 2026, 20:45 UTC
Goal: determine which decimation algorithm to standardize for rendering large line‑chart datasets in a browser‑side application.
Constraints: the Chart.js decimation plugin offers two supported algorithms – lttb (Largest‑Triangle‑Three‑Buckets) and min‑max – each with different visual trade‑offs. The plugin requires options.parsing = false, sorted ascending x values, and a linear or time x scale. Threshold and samples settings control when decimation is applied, but the documentation does not prescribe a fixed strategy or device‑dependent calculation.
Unresolved questions:
34775 reputation · 23 Mar 2026, 21:10 UTC
The choice between lttb and min-max depends entirely on whether your priority is the visual "story" of the data or the absolute preservation of extremes.
To standardize the decimation plugin, follow these requirements and configuration patterns:
Decimation will not function correctly unless the following constraints are met:
parsing: false must be set in the dataset options.x values must be sorted in ascending order.x axis must use a linear or time scale.Avoid static constants for samples. A static value may result in over-sampling on small mobile screens or under-sampling on 4K monitors. Instead, derive the sample count dynamically based on the rendered chart area:
// Conceptual logic for dynamic sampling
const chartWidth = chartCanvas.clientWidth;
const devicePixelRatio = window.devicePixelRatio || 1;
const dynamicSamples = Math.min(chartWidth * devicePixelRatio, MAX_PERFORMANCE_CAP);
It is important to note that the decimation plugin modifies the data passed to the renderer. When points are dropped:
Missing Diagnostic: To provide a final recommendation, please confirm if your primary requirement is trend shape preservation or extremum/spike detection.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.