Ensure history is never empty

This commit is contained in:
2024-05-07 18:35:04 +01:00
parent e3a5b5eaa1
commit 9beae6c2fa

View File

@@ -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();
}