From 9beae6c2fa890172fa0c791f51c3f50fbcd65b4d Mon Sep 17 00:00:00 2001 From: luisdralves Date: Tue, 7 May 2024 18:35:04 +0100 Subject: [PATCH] Ensure history is never empty --- src/client/components/chart-cards/common/chart/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/components/chart-cards/common/chart/index.tsx b/src/client/components/chart-cards/common/chart/index.tsx index 466e020..db967c5 100644 --- a/src/client/components/chart-cards/common/chart/index.tsx +++ b/src/client/components/chart-cards/common/chart/index.tsx @@ -46,7 +46,7 @@ export const CanvasChart = ({ total, hueOffset = 0, domain, hardDomain, data, fo // Record data changes useEffect(() => { if (data) { - while (xFromTimestamp(history.current[0][0], width) < -xMargin) { + while (history.current.length && xFromTimestamp(history.current[0][0], width) < -xMargin) { history.current.shift(); }