File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -147,8 +147,8 @@ const buildSparklinePaths = (
147147 xMax += 1
148148 }
149149
150- let yMin = Math . min ( yMinData , 0 )
151- let yMax = Math . max ( yMaxData , 0 )
150+ let yMin = yMinData
151+ let yMax = yMaxData
152152 if (yMin === yMax ) {
153153 yMin -= 1
154154 yMax += 1
@@ -158,7 +158,9 @@ const buildSparklinePaths = (
158158 ((value - xMin ) / (xMax - xMin )) * SPARKLINE_WIDTH
159159 const scaleY = (value : number ) =>
160160 SPARKLINE_HEIGHT - ((value - yMin ) / (yMax - yMin )) * SPARKLINE_HEIGHT
161- const zeroY = scaleY (0 )
161+ const clamp = (value : number , min : number , max : number ) =>
162+ Math .min (Math .max (value , min ), max )
163+ const zeroY = scaleY (clamp (0 , yMin , yMax ))
162164
163165 const linePaths: string [] = []
164166 const areaPaths: string [] = []
You can’t perform that action at this time.
0 commit comments