Skip to content

[Insights Polish] Chart area and labels - #102969

Merged
cristipaval merged 8 commits into
Expensify:mainfrom
software-mansion-labs:insights/polish-chart-area-labels
Oct 6, 2026
Merged

cristipaval merged 8 commits into
Expensify:mainfrom
software-mansion-labs:insights/polish-chart-area-labels

Conversation

@mhawryluk

@mhawryluk mhawryluk commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Explanation of Change

Updates the chart area styling for the line and vertical bar charts to match the new Insights designs:

  • Gridlines: dashed (4px dash, 8px gap) with rounded ends. victory-native's built-in gridlines can't round their ends, so a new ChartGridLines component draws them behind the chart content.
  • Y-axis: moved to the right side of the chart, right-aligned to the edge of the chart, with a 12px gap between the plot and the labels.
  • Axis label color: x and y axis labels now use the icons theme color instead of textSupporting.
  • Left frame line: removed from the line chart, along with the now-unused LeftFrameLine component.

Also included a bug fix:

  • X-axis label rotation: fixed line chart x labels rotating earlier than they needed to. The line chart moves its first point inward so the first label has room to stay flat, but victory-native shrinks domain padding when it applies it. The resulting space was a few px short, so labels rotated to 45 degrees. The padding is now calculated so the space left after that shrinking is exactly what the label needs.

Horizontal bar charts are intentionally left as they are, since they'll be removed in an upcoming PR. Their only change is passing canvasWidth to ChartYAxisLabels to match its new props.

These changes also apply to Spend charts. They don't change data, interactions, or which labels are shown.

Fixed Issues

$ #102861
PROPOSAL: N/A

Tests

  1. Enable the insightsPage beta.
  2. Go to Insights.
  3. Verify the charts match the new design when it comes to y axis labels placement, labels color and grid lines appearance. (For bar charts, the changes are for vertical ones only and the category labels for vertical bar charts will be removed in a separate PR).
  4. Check the same in Home and Spend.

Offline tests

N/A

QA Steps

  1. With insightsPage beta disabled.
  2. Go to Spend, open a bar chart and then a line chart.
  3. Verify the chart looks correct and the labels on the right are not cut off.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

iOS: Native
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-10-05.at.11.48.09.mov
MacOS: Chrome / Safari
Nagranie.z.ekranu.2026-10-5.o.11.45.26.mov

@codecov

codecov Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
...ents/Charts/BarChart/HorizontalBarChartContent.tsx 4.45% <ø> (ø)
src/components/Charts/VictoryTheme.ts 100.00% <ø> (ø)
src/components/Charts/hooks/useLabelHitTesting.ts 0.00% <ø> (ø)
src/components/Charts/utils/index.ts 73.86% <100.00%> (+0.67%) ⬆️
.../components/Charts/components/ChartXAxisLabels.tsx 0.00% <0.00%> (ø)
.../components/Charts/components/ChartYAxisLabels.tsx 0.00% <0.00%> (ø)
...onents/Charts/BarChart/VerticalBarChartContent.tsx 0.00% <0.00%> (ø)
...rc/components/Charts/components/ChartGridLines.tsx 37.50% <37.50%> (ø)
...c/components/Charts/LineChart/LineChartContent.tsx 3.65% <0.00%> (-0.10%) ⬇️
... and 8 files with indirect coverage changes

@mhawryluk

Copy link
Copy Markdown
Member Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

I found no blocking issues. The layout math checks out, and all CI checks pass except the approval gate.

What I verified
  • Plot bounds match victory-native. With axisSide: 'right' and no axis font, victory-native ends the plot at width - padding.right - labelOffset. The new getVerticalBarPlotBounds mirrors that. So BarChartContent's orientation prediction still matches what VerticalBarChartContent measures after mounting.
  • Y labels fit. Labels end GLYPH_PADDING inside the canvas edge. The widest label leaves a 12px gap to the plot, as the description says (ChartYAxisLabels.tsx:97).
  • Dash compensation is correct. Each round cap adds strokeWidth / 2 at both ends of a dash, so [3, 9] renders as a visible 4px dash and 8px gap (ChartGridLines.tsx:27).
  • The x and y labels don't collide. The last x label can now extend into the right gutter. X labels start labelGap (12px) below the lowest tick, and the lowest y label extends only half a line height below it.
  • Horizontal bar chart: behavior is unchanged, because leftAlign ignores canvasWidth.

Suggestions (non-blocking):

  1. Check long first x labels on narrow widths. The y-label gutter moved from the left to the right. The first x label now has about 5px of left padding instead of the whole gutter. In vertical bar charts, firstTickLeftSpace shrinks, so the first label truncates sooner. The line chart compensates by increasing domainPadding.left, which moves the first point inward. This is probably fine, but check it with a long first label.
  2. Add a small unit test for ChartGridLines. The cap-compensation math is the only logic in the new component, and Codecov reports 42.85% coverage for it.

view run

@mhawryluk
mhawryluk marked this pull request as ready for review October 5, 2026 09:51
@mhawryluk
mhawryluk requested review from a team as code owners October 5, 2026 09:51
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and truph01 and removed request for a team and JmillsExpensify October 5, 2026 09:51
@melvin-bot

melvin-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown

@truph01 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team October 5, 2026 09:51
@mhawryluk

mhawryluk commented Oct 5, 2026 •

Copy link
Copy Markdown
Member Author

@Expensify/design on the design, the $0 label doesn't have the dotted grid line associated with it. I made it so we don't show a line for a label if it's $0, but only if it's the last one. please let me know if a different logic is expected, for example always the bottom label shouldn't have a grid line or maybe always the $0 one instead

that's what it looks like right now:

Zrzut ekranu 2026-10-5 o 11 50 26 Zrzut ekranu 2026-10-5 o 11 50 41 Zrzut ekranu 2026-10-5 o 11 55 27 Zrzut ekranu 2026-10-5 o 11 55 32

@shawnborton

Copy link
Copy Markdown
Contributor

I'll defer to @dannymcclain on this one - I think I would expect the last one to have a line? And I think I might expect the $0 line to be solid? No strong feels, just gut reactions

@OlGierd03 OlGierd03 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

Comment thread src/components/Charts/VictoryTheme.ts Resolved
@dannymcclain

Copy link
Copy Markdown
Contributor

I made it so we don't show a line for a label if it's $0, but only if it's the last one

I think this is actually pretty solid, but reading Shawn's comment:

I'll defer to @dannymcclain on this one - I think I would expect the last one to have a line? And I think I might expect the $0 line to be solid? No strong feels, just gut reactions

I'd be down to see it this way—I removed the bottom/$0 line to keep things cleaner because the 0 is implied by the bottom of the chart, but seeing those charts with negative values, I kinda like the idea of the 0 line being solid to act as a little guidepost.

So let's try Shawn's suggestion here:

  • $0 always gets a solid line (whether it's last or not)
  • Always include a line for the last item (solid if it's 0, dotted if it's not)

Can we also add 12px of top padding/margin to the x-axis? These spots are feeling a little tight to me:
CleanShot 2026-10-05 at 7 57 05 AM@2x

@mhawryluk

mhawryluk commented Oct 5, 2026 •

Copy link
Copy Markdown
Member Author

So let's try Shawn's suggestion here:

  • $0 always gets a solid line (whether it's last or not)
  • Always include a line for the last item (solid if it's 0, dotted if it's not)

Can we also add 12px of top padding/margin to the x-axis? These spots are feeling a little tight to me

sure, done:

Zrzut ekranu 2026-10-5 o 16 08 47 Zrzut ekranu 2026-10-5 o 16 08 08 Zrzut ekranu 2026-10-5 o 16 09 05 Zrzut ekranu 2026-10-5 o 16 11 19

@dannymcclain

Copy link
Copy Markdown
Contributor

I think that looks pretty great. @shawnborton (and @dubielzyk-expensify) what do you think?

@shawnborton

Copy link
Copy Markdown
Contributor

Big fan personally, that feels much more expected.

@luacmartins

Copy link
Copy Markdown
Contributor

Cool, @mhawryluk we have a failing jest check. @truph01 can you prioritize this review please?

@dubielzyk-expensify

Copy link
Copy Markdown
Contributor

I think that looks pretty great. @shawnborton (and @dubielzyk-expensify) what do you think?

Agree. That looks good to me 👍

@truph01

truph01 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained """"why"""" the code was doing something instead of only explaining """"what"""" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-10-06.at.09.57.57.mov
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-10-06.at.09.50.59.mov

@truph01

truph01 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Code changes look good!

@mhawryluk Could you resolve the failing check?

@mhawryluk

mhawryluk commented Oct 6, 2026 •

Copy link
Copy Markdown
Member Author

@mhawryluk Could you resolve the failing check?

resolved by merging main

@cristipaval
cristipaval merged commit 2af84db into Expensify:main Oct 6, 2026
35 of 37 checks passed
@OSBotify

OSBotify commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🚧 cristipaval has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify OSBotify mentioned this pull request Oct 6, 2026
100 tasks done
@OSBotify

OSBotify commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/cristipaval in version: 9.5.4-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update is needed: this PR only changes chart styling (dashed gridlines, right-side y-axis labels, label color) and fixes x-axis label rotation, and no article under docs/articles describes chart gridlines or axis placement.


view run

@OSBotify

OSBotify commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.5.4-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants