Skip to content

Commit

Permalink
fix: Support for negative values #284 (#291)
Browse files Browse the repository at this point in the history
start from negative value rather than 0 and end at 0
if secondaryValue<0

Co-authored-by: Richard Nolan <[email protected]>
  • Loading branch information
RichardNolan and Richard Nolan authored Jul 6, 2022
1 parent 7c71ed4 commit df31cad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/seriesTypes/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ function getSecondaryStart<TDatum>(
return secondaryAxis.scale(datum.stackData?.[0] ?? NaN) ?? NaN
}

return secondaryAxis.scale(0) ?? NaN
return (
secondaryAxis.scale(datum.secondaryValue < 0 ? datum.secondaryValue : 0) ??
NaN
)
}

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

return secondaryAxis.scale(datum.secondaryValue) ?? NaN
return (
secondaryAxis.scale(datum.secondaryValue < 0 ? 0 : datum.secondaryValue) ??
NaN
)
}

function clampPxToAxis<TDatum>(
Expand Down

0 comments on commit df31cad

Please sign in to comment.