Skip to content
Snippets Groups Projects
Unverified Commit ff36d1ef authored by Sreetam Das's avatar Sreetam Das Committed by GitHub
Browse files

Add computed padding for handling clipped large Net worth amounts (#2818)


* Add computed padding for handling clipped Net worth amounts

* Add comment, early handle 5 character case

* Add release note

* Update packages/desktop-client/src/components/reports/graphs/NetWorthGraph.tsx

Co-authored-by: default avatarRobert Dyer <rdyer@unl.edu>

* Update vrt snapshots

* Fix NetWorthGraph cutoff when `compact` is true

This happens in case of `ReportCard`

* Update VRT snapshots to revert to original

* Revert snapshots to original

* vrt

---------

Co-authored-by: default avatarRobert Dyer <rdyer@unl.edu>
Co-authored-by: default avataryoungcw <calebyoung94@gmail.com>
parent cbbbaf65
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -121,7 +121,12 @@ export function NetWorthGraph({ ...@@ -121,7 +121,12 @@ export function NetWorthGraph({
width={width} width={width}
height={height} height={height}
data={graphData.data} data={graphData.data}
margin={{ top: 0, right: 0, left: 0, bottom: 0 }} margin={{
top: 0,
right: 0,
left: compact ? 0 : computePadding(graphData.data),
bottom: 0,
}}
> >
{compact ? null : ( {compact ? null : (
<CartesianGrid strokeDasharray="3 3" vertical={false} /> <CartesianGrid strokeDasharray="3 3" vertical={false} />
...@@ -180,3 +185,22 @@ export function NetWorthGraph({ ...@@ -180,3 +185,22 @@ export function NetWorthGraph({
</Container> </Container>
); );
} }
/**
* Add left padding for Y-axis for when large amounts get clipped
* @param netWorthData
* @returns left padding for Net worth graph
*/
function computePadding(netWorthData: Array<{ y: number }>) {
/**
* Convert to string notation, get longest string length
*/
const maxLength = Math.max(
...netWorthData.map(({ y }) => {
return Math.round(y).toLocaleString().length;
}),
);
// No additional left padding is required for upto 5 characters
return Math.max(0, (maxLength - 5) * 5);
}
---
category: Bugfix
authors: [sreetamdas]
---
Fix Net Worth amounts being clipped when over 5 characters
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment