Skip to content

[Insights Polish] Bar chart's bars and category labels - #102991

Merged
luacmartins merged 8 commits into
Expensify:mainfrom
software-mansion-labs:insights/bar-charts-polish
Oct 6, 2026
Merged

luacmartins merged 8 commits into
Expensify:mainfrom
software-mansion-labs:insights/bar-charts-polish

Conversation

@mhawryluk

@mhawryluk mhawryluk commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Explanation of Change

Updates bar charts to match the new Insights designs:

  • Removed horizontal bars: bar charts are always vertical. This deletes HorizontalBarChartContent, useBarChartOrientation, the orientation dispatcher, and the helpers only they used.
  • Bar sizing: bars fill the plot with a 16px gap between them, and the outer bars sit flush with the plot edges. The gap shrinks only when there are too many bars for it. Corners use a 4px radius.
  • Bar labels: labels under the bars are hidden when the inline table below the chart already names each item. When they're hidden, label measurement and layout are skipped. Spend has no list, so it keeps its labels.
  • Home: Home now also asks Search to calculate totals. Without totals, the response leaves out each group's share of spend, so we don't show percentage data.
  • Colors: bars use the multicolor palette again. This removes the fixed Top spenders and Top merchants colors and the now-unused color prop.
  • Bar hover and tap area: each bar's target covers the full plot height plus a small overhand on each side on the x axis.

Outside the insightsPage beta, Spend and Home bar charts also get the wider bars and 4px corners. Their labels are unchanged.

Fixed Issues

$ #102863
PROPOSAL: N/A

Tests

  1. Enable the insightsPage beta.
  2. Open Insights on wide and narrow layouts.
  3. Verify Top spenders and Top merchants are vertical bars, with a different color per bar.
  4. Verify there are no labels under the bars.
  5. Verify bars fill the plot with 16px gaps and 4px corners.
  6. Hover and click a bar. Verify the hit box covers full y axis, not just the bar. Verify the tooltip shows, and clicking opens the filtered Spend page.
  7. Open Spend, group expenses by category, and switch to the Bar view.
  8. Verify labels show under the bars, rotating or shortening as before.
  9. Verify that with many groups, the bars stay separated and don't overlap.
  10. Open a Spend bar chart with a single group. Verify the bar is centered, has max-width set and nothing is cut off.

Offline tests

N/A

QA Steps

  1. With insightsPage beta disabled.
  2. Open the bar charts on Home and Spend.
  3. Verify bars and labels still display correctly, nothing is clipped.

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.14.16.29.mov
MacOS: Chrome / Safari
Nagranie.z.ekranu.2026-10-5.o.13.58.10.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 Δ
src/components/Charts/BarChart/BarChartContent.tsx 0.00% <ø> (-5.00%) ⬇️
src/components/Charts/BarChart/index.tsx 0.00% <ø> (ø)
src/components/Charts/VictoryTheme.ts 100.00% <ø> (ø)
src/components/Charts/barChartConstants.ts 100.00% <100.00%> (ø)
...rc/components/Charts/hooks/useChartInteractions.ts 47.05% <ø> (-0.05%) ⬇️
src/components/Charts/hooks/useChartLabelLayout.ts 100.00% <ø> (ø)
src/components/Charts/utils/index.ts 77.65% <100.00%> (+3.78%) ⬆️
src/components/Search/buildChartSeries.ts 100.00% <100.00%> (ø)
src/pages/Insights/charts/InsightsChartWidget.tsx 0.00% <ø> (ø)
src/pages/Insights/dashboardSpecs.ts 25.00% <ø> (ø)
... and 7 more
... and 9 files with indirect coverage changes

@mhawryluk

Copy link
Copy Markdown
Member Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Code review

I found no blocking bugs. The cleanup removes every horizontal-bar symbol without leaving a dangling reference, and the hidden-label path works: an empty label layout returns xAxisLabelHeight: 0, so the Y-axis labels still render. Three things are worth a look:

  1. One or two bars now fill the whole plot. getBarLayout sets the gap to 0 for a single bar, so barWidth equals plotWidth. Before this PR, one bar took about 70% of the plot. A workspace with one spender, merchant, or category will show one card-wide block on Home and Insights. Two bars are each about half the plot wide. If the design doesn't call for this, add a max bar width (and center the bars when they hit it).
  2. The hook rename looks accidental. useHomeInsightConfigs.ts now defines and exports useSearchTypeMenuItems, but the file name, its doc comment, and the import in InsightsSectionContent all still say useHomeInsightConfigs. I suggest keeping the original name.
  3. Home now requests totals for every user. useInsightData.ts:43 always sets shouldCalculateTotals: true, but only users with the Insights beta see the percentages. If calculating totals costs the backend extra work, turn it on only when the beta is enabled.

Minor: BAR_CORNER_RADIUS has no doc comment, unlike the other constants in barChartConstants.ts. The PR body still needs the Tests, Offline tests, and QA steps. That's why the checklist check fails; all other CI checks pass.


view run

@mhawryluk

Copy link
Copy Markdown
Member Author
  1. One or two bars now fill the whole plot.

I think that's expected, right? @dannymcclain

Zrzut ekranu 2026-10-5 o 14 16 42
  1. The hook rename looks accidental.

fixed!

  1. Home now requests totals for every user.

we do show the percentOfTotal data outside of beta too, in the tooltips

@mhawryluk
mhawryluk marked this pull request as ready for review October 5, 2026 12:19
@mhawryluk
mhawryluk requested review from a team as code owners October 5, 2026 12:19
@melvin-bot
melvin-bot Bot requested review from truph01 and removed request for a team October 5, 2026 12:19
@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 requested review from JmillsExpensify and removed request for a team October 5, 2026 12:19
@dannymcclain

Copy link
Copy Markdown
Contributor
  1. One or two bars now fill the whole plot.

I think that's expected, right? @dannymcclain

Yeah I suppose this is expected with the new bar paradigm. @JmillsExpensify @Expensify/design should we maybe add a max-width to these bars so we don't get this situation?

Something like this perhaps?

CleanShot 2026-10-05 at 7 45 53 AM@2x

Here I'm using a max-width of 320px for the bars - but I just picked that semi-arbitrarily. TBH I'm not super duper concerned with this situation as it's really not our mainline use case here.

Copy link
Copy Markdown
Contributor

Yeah, great catch. I'm a fan of using max-width for this case. No passionate on the actual width we land on, though your example looks fine.

@shawnborton

Copy link
Copy Markdown
Contributor

Big fan of that idea!

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

This comment has been minimized.

@JmillsExpensify JmillsExpensify 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.

The charts look really good!

@JmillsExpensify

Copy link
Copy Markdown
Contributor

@truph01 this is ready for your review. Please prioritize when you're next online.

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Also heads up that I noticed something in this PR, not sure if it's coming from this one or another one: On Home we are showing the table. We want to ensure that's an "Insight-exclusive." The overarching design for Home is that it's a preview of things, you can go to other parts of the app for details.

@mhawryluk

Copy link
Copy Markdown
Member Author

Also heads up that I noticed something in this PR, not sure if it's coming from this one or another one: On Home we are showing the table. We want to ensure that's an "Insight-exclusive." The overarching design for Home is that it's a preview of things, you can go to other parts of the app for details.

yeah, it's coming from this PR, I'll remove it. should the Home bar charts keep their X axis labels then too?

JmillsExpensify commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

That's a great question. Danny, for Insights we show the x-axis for the headline/spend over time graph, but we don't show them for the ranking/top graphs. Should we keep that the same on Home too?

@mhawryluk

Copy link
Copy Markdown
Member Author

Stale "horizontal bar fallback signal" tests

Now that no caller treats 90° as "switch to horizontal bars", could we drop the horizontal bar fallback signal block in useChartLabelLayout.test.ts?

removed!

@mhawryluk

Copy link
Copy Markdown
Member Author

removed the inline table and the group labels from Home's insights widget and limited the bar width to 320px:

Zrzut ekranu 2026-10-6 o 11 09 43 Zrzut ekranu 2026-10-6 o 11 10 02

@mhawryluk

mhawryluk commented Oct 6, 2026 •

Copy link
Copy Markdown
Member Author

and while keeping in mind that we want to focus on Home and Insights for now, I'd like to make sure it's clear how this PR changes the bar charts in Spend: we keep the group labels there and remove the horizontal fallback when labels rotate to 90 degrees (undoes #99939) (cc: @Expensify/design)

Zrzut ekranu 2026-10-6 o 11 15 55

@mhawryluk

Copy link
Copy Markdown
Member Author

@truph01 back to you

@mhawryluk
mhawryluk requested a review from truph01 October 6, 2026 09:19
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

This comment has been minimized.

@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.16.27.37.mov
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
output.mp4

@truph01

truph01 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

@mhawryluk On mobile devices, I’m unable to long-press to see the details. Should we support long-press on mobile to show the details, similar to how we allow users to hover over the chart on wide screens?

Screen.Recording.2026-10-06.at.16.31.17.mov

@JmillsExpensify

JmillsExpensify commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

On mobile devices, I’m unable to long-press to see the details. Should we support long-press on mobile to show the details, similar to how we allow users to hover over the chart on wide screens?

We could, though this is currently the design spec (from the tracking issue).

On desktop, clicking a bar, line point, or slice still opens the Spend page filtered to that data, unchanged from today.

On mobile, tap shows the tooltip, and there is no tap-to-drill-in. Drilling into Spend on mobile happens from each card's ⋮ menu, using the existing View on Spend action.

I don't feel strongly about this, though the long-term design is to no longer take you to the Spend page on either platform, and instead, keep you on the Insights page.

@mhawryluk

Copy link
Copy Markdown
Member Author

yeah, we'll implement changes regarding tap on mobile as part of this issue: #102865

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Let's hold on merging this PR until Danny is online.

@dannymcclain

Copy link
Copy Markdown
Contributor

This is looking great to me 🚀

And it will be even better once we implement the mobile tooltip changes—I know they're coming 😁 we just really need them for the mobile experience to make sense haha.

@luacmartins

Copy link
Copy Markdown
Contributor

We got the blessing from @dannymcclain, gonna merge!

@luacmartins
luacmartins merged commit 98d321a into Expensify:main Oct 6, 2026
37 of 39 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

🚧 luacmartins 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/luacmartins in version: 9.5.4-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR only changes how bar charts look: bar width, gaps, corners, colors, and labels. Horizontal bars and hidden labels were only visible behind the insightsPage beta. No article sentence becomes incorrect. The "Bar View" description in How to Use Insights in Expensify still matches the app.

@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.

9 participants