Skip to content

Commit df31cad

Browse files
RichardNolanRichard Nolan
and
Richard Nolan
authored
fix: Support for negative values #284 (#291)
start from negative value rather than 0 and end at 0 if secondaryValue<0 Co-authored-by: Richard Nolan <[email protected]>
1 parent 7c71ed4 commit df31cad

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/seriesTypes/Bar.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ function getSecondaryStart<TDatum>(
192192
return secondaryAxis.scale(datum.stackData?.[0] ?? NaN) ?? NaN
193193
}
194194

195-
return secondaryAxis.scale(0) ?? NaN
195+
return (
196+
secondaryAxis.scale(datum.secondaryValue < 0 ? datum.secondaryValue : 0) ??
197+
NaN
198+
)
196199
}
197200

198201
function getSecondary<TDatum>(
@@ -203,7 +206,10 @@ function getSecondary<TDatum>(
203206
return secondaryAxis.scale(datum.stackData?.[1] ?? NaN) ?? NaN
204207
}
205208

206-
return secondaryAxis.scale(datum.secondaryValue) ?? NaN
209+
return (
210+
secondaryAxis.scale(datum.secondaryValue < 0 ? 0 : datum.secondaryValue) ??
211+
NaN
212+
)
207213
}
208214

209215
function clampPxToAxis<TDatum>(

0 commit comments

Comments
 (0)