Skip to content

Commit 595db53

Browse files
committed
perf: Optimize chart rendering by setting tension to 0 and removing decimation
1 parent 77fdb25 commit 595db53

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/components/ChartContainer.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
Tooltip,
1313
Legend,
1414
} from 'chart.js';
15-
import zoomPlugin from 'chartjs-plugin-zoom';
1615

1716
ChartJS.register(
1817
CategoryScale,
@@ -21,8 +20,7 @@ ChartJS.register(
2120
LineElement,
2221
Title,
2322
Tooltip,
24-
Legend,
25-
zoomPlugin
23+
Legend
2624
);
2725

2826
// Chart wrapper component with error boundary
@@ -542,7 +540,7 @@ export default function ChartContainer({
542540
backgroundColor: `${color}33`, // Add transparency
543541
borderWidth: 2,
544542
fill: false,
545-
tension: 0.1,
543+
tension: 0, // 设置 tension 为 0,绘制直线段
546544
pointRadius: 0, // 默认不显示数据点
547545
pointHoverRadius: 4, // hover时显示实心圆点,半径为4
548546
pointBackgroundColor: color, // 设置点的背景色
@@ -579,7 +577,7 @@ export default function ChartContainer({
579577
backgroundColor: '#dc2626',
580578
borderWidth: 2,
581579
fill: false,
582-
tension: 0.1,
580+
tension: 0, // 设置 tension 为 0,绘制直线段
583581
pointRadius: 0, // 默认不显示数据点
584582
pointHoverRadius: 4, // hover时显示实心圆点
585583
pointBackgroundColor: '#dc2626', // 设置点的背景色

0 commit comments

Comments
 (0)