Skip to content

[Payment due @situchan] [No QA] Victory Chart: Support horizontal bars#91659

Merged
luacmartins merged 26 commits into
Expensify:mainfrom
s77rt:horizontal-charts
May 27, 2026
Merged

[Payment due @situchan] [No QA] Victory Chart: Support horizontal bars#91659
luacmartins merged 26 commits into
Expensify:mainfrom
s77rt:horizontal-charts

Conversation

@s77rt

@s77rt s77rt commented May 26, 2026

Copy link
Copy Markdown
Member

Explanation of Change

  • Added support for horizontal bars. This works by basically swapping x, y pretty much everywhere (points, axis, domains, etc).
  • I have also added a patch for victory-native to do the same in useBarGroupPaths hook so the bars are rendered correctly

Fixed Issues

https://github.com/Expensify/Expensify/issues/636601
PROPOSAL:

Tests

  1. Open report
  2. Add comment
  3. Note reportID and reportActionID
  4. Run code:
const html2 = `<victorychart horizontal domain="{y: [0, 18000]}" domainpadding="{x: 44, y: 16}" height="464" width="680" padding="{top: 92, bottom: 84, left: 150, right: 32}" style="{ parent: { backgroundColor: '#F7F2EF', borderRadius: 16, width: '100%', maxWidth: 680, }, }" categories="{x: ['Ethan Brooks', 'Sofia Ramirez', 'Michelina Della Donna', 'Priya Patel', 'Alex Chen']}"><victorylabel x="32" y="40" text='Top employees by spend' style="{ fill: '#002E22', fontSize: 17, fontWeight: 700, fontFamily: 'Expensify Neue', }"/><victorylabel x="32" y="62" text='As of: May 6, 12:49 PM PT' style="{ fill: '#73857E', fontSize: 11, fontWeight: 400, fontFamily: 'Expensify Neue', }"/><victoryaxis tickValues="[0,1,2,3,4]" tickformat="['Ethan Brooks', 'Sofia Ramirez', 'Michelina Della Donna', 'Priya Patel', 'Alex Chen']" style="{ axis: {stroke: 'transparent'}, ticks: {stroke: 'transparent'}, grid: {stroke: 'transparent'}, tickLabels: { fill: '#73857E', fontSize: 11, fontWeight: 500, fontFamily: 'Expensify Neue', padding: 24, }, }"/><victoryaxis dependentaxis tickvalues="[0, 3000, 6000, 9000, 12000, 15000, 18000]" tickformat="['$0', '$3,000', '$6,000', '$9,000', '$12,000', '$15,000', '$18,000']" style="{ axis: {stroke: 'transparent'}, ticks: {stroke: 'transparent'}, grid: {stroke: '#E6E1DA', strokeWidth: 1}, tickLabels: { fill: '#73857E', fontSize: 11, fontWeight: 500, fontFamily: 'Expensify Neue', padding: 8, }, }"/><victorygroup horizontal offset="18"><victorybar barwidth="16" cornerradius="{top: 8, bottom: 0}" style="{data: {fill: '#13C96B'}}" data="[ {x: 'Ethan Brooks', y: 9450}, {x: 'Sofia Ramirez', y: 10500}, {x: 'Michelina Della Donna', y: 11900}, {x: 'Priya Patel', y: 13400}, {x: 'Alex Chen', y: 14300}, ]"/><victorybar barwidth="16" cornerradius="{top: 8, bottom: 0}" style="{data: {fill: '#1E90F2'}}" data="[ {x: 'Ethan Brooks', y: 8800}, {x: 'Sofia Ramirez', y: 10250}, {x: 'Michelina Della Donna', y: 11250}, {x: 'Priya Patel', y: 13900}, {x: 'Alex Chen', y: 12500}, ]"/></victorygroup><victorylegend x="250" y="416" orientation='horizontal' gutter="42" symbolspacer="10" style="{ labels: { fill: '#002E22', fontSize: 13, fontWeight: 500, fontFamily: 'Expensify Neue', }, }" data="[ {name: 'This month', symbol: {type: 'circle', fill: '#13C96B', size: 6}}, {name: 'Last month', symbol: {type: 'circle', fill: '#1E90F2', size: 6}}, ]"/></victorychart>`;

Onyx.merge("reportActions_[report ID]", {
    "[report action ID]": { message: [{ html: html2, type: "COMMENT" }] },
});
  1. Verify the chart looks same as follow
Screenshot 2026-05-26 at 6 54 21 AM
  • Verify that no errors appear in the JS console

Offline tests

n/a

QA Steps

n/a

  • Verify that no errors appear in the JS console

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 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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 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 a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@codecov

codecov Bot commented May 26, 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 Δ
...ers/VictoryChartRenderer/parsers/parserRegistry.ts 100.00% <ø> (ø)
...eport/ReportActionCompose/ComposerActionButton.tsx 100.00% <ø> (ø)
...ChartRenderer/components/VictoryChartCartesian.tsx 9.09% <0.00%> (+1.39%) ⬆️
...ctoryChartRenderer/context/VictoryChartContext.tsx 10.00% <0.00%> (ø)
...oryChartRenderer/components/VictoryChartSeries.tsx 16.66% <0.00%> (-1.52%) ⬇️
...s/VictoryChartRenderer/utils/parseDomainPadding.ts 0.00% <0.00%> (ø)
...rers/VictoryChartRenderer/utils/parseCategories.ts 0.00% <0.00%> (ø)
...enderers/VictoryChartRenderer/utils/parseOffset.ts 0.00% <0.00%> (ø)
...VictoryChartRenderer/parsers/victoryChartParser.ts 0.00% <0.00%> (ø)
...ictoryChartRenderer/parsers/victorySeriesParser.ts 0.00% <0.00%> (ø)
... and 5 more
... and 268 files with indirect coverage changes

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@s77rt s77rt marked this pull request as ready for review May 26, 2026 05:58
@s77rt s77rt requested review from a team as code owners May 26, 2026 05:58
@melvin-bot melvin-bot Bot requested review from pecanoro and trjExpensify and removed request for a team May 26, 2026 05:58
@melvin-bot

melvin-bot Bot commented May 26, 2026

Copy link
Copy Markdown

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

@s77rt s77rt requested review from luacmartins, roryabraham and situchan and removed request for pecanoro May 26, 2026 05:59
@melvin-bot

melvin-bot Bot commented May 27, 2026

Copy link
Copy Markdown

🎯 @situchan, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - no internal issue.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

@MelvinBot

Copy link
Copy Markdown
Contributor

Regression Analysis

1. betweenGroupPadding changed for ALL bar groups (including existing vertical charts)

Previously, VictoryChartBarGroup used a hardcoded BAR_BETWEEN_GROUP_PADDING = 2/3. Now it dynamically computes the value via parseOffset(). For existing vertical grouped bar charts without an offset attribute, the formula becomes:

offset = 0  →  groupWidth = barWidth  →  betweenGroupPadding = 1 - (barWidth * pointsCount / boundSize)

This produces a different value than the old constant 0.667, meaning existing vertical grouped bar chart spacing will change. This is the highest-risk regression in this PR.

2. displayName still has the old typo

The component was renamed from VictoryCharBarGroupVictoryChartBarGroup, but the displayName on line 55 still reads 'VictoryCharBarGroup' (missing the t in "Chart"). Minor — only affects React DevTools — but worth fixing for consistency.

3. Non-horizontal chart paths are safe

I verified that for isHorizontal = false/undefined, all conditional branches in the axis parser, series parser, domain parser, and domain-padding parser fall through to logic identical to the pre-PR behavior. No regression there.

4. parseDomainPadding signature change is safe

The added isHorizontal parameter only affects parseDomainPadding, which is only called from victoryChartParser.ts. No other callers exist.

5. processVictoryChartTree signature change is safe

The new rootProcessedResult parameter is only passed from the single external call site in VictoryChartContext.tsx (as null) and from the recursive self-call.

6. Unrelated change: ComposerActionButton.tsx

Adds import React from 'react' — benign, but unrelated to horizontal bars. Should probably be in a separate commit.


TL;DR: The main regression risk is item #1 — the betweenGroupPadding calculation change affects all grouped bar charts, not just horizontal ones. Existing vertical grouped bar charts will render with different bar spacing.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14cab875af

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

roryabraham
roryabraham previously approved these changes May 27, 2026
@situchan

Copy link
Copy Markdown
Contributor

Please check bot reviews and address valid ones

@roryabraham

Copy link
Copy Markdown
Contributor

@s77rt can you look at the AI review comments?

@s77rt s77rt dismissed stale reviews from roryabraham and luacmartins via ca27658 May 27, 2026 14:39
@s77rt

s77rt commented May 27, 2026

Copy link
Copy Markdown
Member Author

Bug: This month / Last month is overlapped with x labels on vertical chart

Screenshot 2026-05-27 at 1 34 29 PM

Yeah I noticed this. it seems that the Victory Chart padding is not exactly same as Victory Native padding, or I'm missing something, This is something that I didn't catch in the initial PR since in the first chart Monthly Spend the legend is also closer to the x-axis labels than in the expected result. Let's not block on this since the main target charts look good enough (the diff is not visible and no overlapping - let's fix this later though)

@s77rt

s77rt commented May 27, 2026

Copy link
Copy Markdown
Member Author

@roryabraham @luacmartins Should be good to merge

@luacmartins

Copy link
Copy Markdown
Contributor

Merging since @roryabraham had already approved

@luacmartins luacmartins merged commit 8c3826c into Expensify:main May 27, 2026
62 of 77 checks passed
@OSBotify

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

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.3.84-0 🚀

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

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

I reviewed the changes in this PR against the help site files under App/docs/articles.

No help site changes are required.

This PR adds internal support for rendering horizontal bar charts in the Victory Chart HTML renderer. The changes are entirely in chart component code (parsers, context, victory-native patch) and do not introduce any new user-facing feature, setting, or workflow that would need documentation. The existing insights articles already reference bar charts at the appropriate level of abstraction — the horizontal orientation is a rendering detail controlled by chart HTML, not a user-facing option.

@s77rt, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.3.86-0 🚀

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

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

I reviewed the changes in this PR and the existing help site articles under App/docs/articles.

No help site changes are required.

This PR adds horizontal bar chart support to the internal Victory Chart renderer (VictoryChartRenderer components and parsers). It's a rendering capability enhancement for charts embedded in HTML messages — it doesn't introduce any new user-facing features, settings, UI labels, or workflows that are covered by the help site documentation.

The existing Insights articles describe chart view modes (Bar, Line, Table, Pie) at a high level and don't specify bar orientation details, so no updates are needed there either.

@s77rt, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.3.88-0 🚀

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

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

I reviewed all the changes in this PR and the existing help site articles under App/docs/articles.

No help site changes are required.

This PR adds internal support for rendering horizontal bar charts in the VictoryChart HTML renderer. All changes are in the rendering engine (parsers, components, context, victory-native patch) and don't introduce any new user-facing features, settings, or workflows that would need documentation.

The existing Insights documentation already covers "Bar View" as a chart type. Whether a bar chart renders horizontally or vertically is determined by the chart HTML from the backend — it's not a user-configurable setting.

@s77rt, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.3.88-2 🚀

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

@melvin-bot

melvin-bot Bot commented May 28, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #92015

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.

6 participants