Skip to content

Commit e646eeb

Browse files
committed
Add decimation for large chart datasets
1 parent 04e722b commit e646eeb

4 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/components/ChartContainer.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Title,
1212
Tooltip,
1313
Legend,
14+
Decimation,
1415
} from 'chart.js';
1516
import zoomPlugin from 'chartjs-plugin-zoom';
1617
import { ImageDown, Copy, FileDown } from 'lucide-react';
@@ -25,6 +26,7 @@ ChartJS.register(
2526
Title,
2627
Tooltip,
2728
Legend,
29+
Decimation,
2830
zoomPlugin
2931
);
3032

@@ -388,6 +390,12 @@ export default function ChartContainer({
388390
responsiveAnimationDuration: 0,
389391
interaction: { mode: 'nearest', intersect: false, axis: 'x' },
390392
plugins: {
393+
decimation: {
394+
enabled: true,
395+
algorithm: 'lttb',
396+
samples: 2000,
397+
threshold: 4000
398+
},
391399
zoom: {
392400
pan: {
393401
enabled: true,

src/components/__tests__/AppConfigPersistence.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ vi.mock('chart.js', () => {
2222
Title: {},
2323
Tooltip: {},
2424
Legend: {},
25+
Decimation: {},
2526
};
2627
});
2728

src/components/__tests__/ChartContainer.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ vi.mock('chart.js', () => {
2020
Title: {},
2121
Tooltip: {},
2222
Legend: {},
23+
Decimation: {},
2324
};
2425
});
2526

src/components/__tests__/GlobalConfigOverride.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ vi.mock('chart.js', () => {
2222
Title: {},
2323
Tooltip: {},
2424
Legend: {},
25+
Decimation: {},
2526
};
2627
});
2728

0 commit comments

Comments
 (0)