Skip to content

Commit df18831

Browse files
authored
Fix chart render (#842)
1 parent ef77313 commit df18831

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/ui/components/chart/Chart.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export function Chart<T>({
200200
return;
201201
}
202202

203+
chartPointsRef.current = [];
203204
chartRef.current = new ChartJS(ctx, {
204205
...DEFAULT_CONFIG,
205206
data: {
@@ -286,15 +287,17 @@ export function Chart<T>({
286287
};
287288
}, [onRangeSelectEvent, datasetConfig, plugins, tooltip, interaction]);
288289

289-
if (!equal(chartPointsRef.current, chartPoints) && chartRef.current) {
290-
updateChartPoints({
291-
chart: chartRef.current,
292-
prevPoints: chartPointsRef.current,
293-
nextPoints: chartPoints,
294-
theme,
295-
});
296-
chartPointsRef.current = chartPoints;
297-
}
290+
useEffect(() => {
291+
if (!equal(chartPointsRef.current, chartPoints) && chartRef.current) {
292+
updateChartPoints({
293+
chart: chartRef.current,
294+
prevPoints: chartPointsRef.current,
295+
nextPoints: chartPoints,
296+
theme: themeRef.current,
297+
});
298+
chartPointsRef.current = chartPoints;
299+
}
300+
}, [chartPoints]);
298301

299302
return (
300303
<div style={{ position: 'relative', height: CHART_HEIGHT, ...style }}>

0 commit comments

Comments
 (0)