Skip to content

Commit

Permalink
end of year charts no longer go out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
rhernandez-intertech committed Mar 14, 2024
1 parent be3b6ab commit 10e2f9b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/YearRecapCharts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,26 @@ export default function YearRecapChart(props: BarsProps) {
}),
[xMax],
);

let yDomain: number = 0;
let barGraphDataMax: number = 0;
props.barGraphData.forEach(data => {
if(data > barGraphDataMax){
barGraphDataMax = data;
}
});
if (barGraphDataMax > props.domainYaxis){
yDomain = Math.ceil(barGraphDataMax);
} else {
yDomain = props.domainYaxis;
}

const yScale = useMemo(
() =>
scaleLinear<number>({
range: [yMax, 0],
round: true,
domain: [0, props.domainYaxis],
domain: [0, yDomain],
}),
[yMax],
);
Expand Down

0 comments on commit 10e2f9b

Please sign in to comment.