Fix label clipping for both Cartesian charts#83452
Fix label clipping for both Cartesian charts#83452Julesssss merged 15 commits intoExpensify:mainfrom
Conversation
|
|
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@ShridharGoel Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| ); | ||
| }; | ||
|
|
||
| const labelSpace = AXIS_LABEL_GAP + (xAxisLabelHeight ?? 0); |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
The following block is duplicated verbatim in LineChartContent.tsx (lines 172-174):
const labelSpace = AXIS_LABEL_GAP + (xAxisLabelHeight ?? 0);
const dynamicChartStyle = {height: CHART_CONTENT_MIN_HEIGHT + labelSpace};
const chartPadding = {...CHART_PADDING, bottom: labelSpace + CHART_PADDING.bottom};Additionally, the boundsLeft/boundsRight state declarations, the totalDomainPadding/paddingScale calculations, and the firstTickLeftSpace/lastTickRightSpace formulas are also duplicated between both chart components.
Consider extracting the shared edge-space and chart-padding logic into a shared hook (e.g., useChartEdgeLayout) that encapsulates boundsLeft/boundsRight state, paddingScale computation, edge space arguments for useChartLabelLayout, and the labelSpace/dynamicChartStyle/chartPadding derivations.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
I think the cost of abstraction is higher than the potential benefit in this case. However, since this is more a matter of opinion than fact, I won’t give it a thumbs up or a thumbs down.
There was a problem hiding this comment.
Nevertheless I'm curious about your thoughts @ShridharGoel
There was a problem hiding this comment.
Might be fine leaving it like this
Reviewer Checklist
Screenshots/Videos |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #81964 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
|
🚧 @Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.3.32-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.32-3 🚀
|









Explanation of Change
X-axis labels in both
BarChartandLineChartwere being clipped at the edges of the canvas. The root cause was thatuseChartLabelLayouthad no knowledge of the actual canvas-edge constraints, it only checked whether labels fit between ticks, but never verified whether the first/last labels overflowed past the visible area.What changed
Custom X-axis label rendering: Replaced Victory Native's built-in
XAxislabel rendering with a sharedChartXAxisLabelscomponent rendered viarenderOutside. This renders labels in the full canvas area (outside the clipped plot region), giving us full control over positioning and preventing canvas clipping.Edge-aware layout algorithm: Extended
useChartLabelLayoutwithfirstTickLeftSpaceandlastTickRightSpaceparameters so it knows how much room each edge label has before hitting the canvas boundary. The rotation/truncation/skip progression now accounts for edge overflow:Removed two Victory Native patches: The custom rendering approach eliminates the need for both:
victory-native+41.20.2+001+fix-rotated-label-bounds-check.patch(fixed Victory's flawed rotated label bounds check)victory-native+41.20.2+002+add-label-overflow-prop.patch(added a customlabelOverflowprop)These patches were workarounds for Victory's internal label rendering since we now render labels ourselves, they are no longer needed.
Fixed Issues
$ #81964
PROPOSAL:
Tests
QA Steps
..., but never cut off by the canvas boundary.Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari