From 3d52bcebc05a7db70af0f99dafbd62e84c9a8b4b Mon Sep 17 00:00:00 2001 From: Nodonisko Date: Sun, 5 Mar 2023 17:54:31 +0100 Subject: [PATCH] fix: graph is not showing if all points have same value --- src/CreateGraphPath.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CreateGraphPath.ts b/src/CreateGraphPath.ts index 67e9a2e..260a9ec 100644 --- a/src/CreateGraphPath.ts +++ b/src/CreateGraphPath.ts @@ -101,6 +101,8 @@ export const getYPositionInRange = ( value: number, yRange: GraphYRange ): number => { + if (yRange.min === yRange.max) return 0.5 // Prevent division by zero (NaN) + const diff = yRange.max - yRange.min const y = value