Skip to content

feat: Add SearchLineChart component#81049

Merged
puneetlath merged 27 commits intoExpensify:mainfrom
software-mansion-labs:add-search-line-chart-component
Feb 5, 2026
Merged

feat: Add SearchLineChart component#81049
puneetlath merged 27 commits intoExpensify:mainfrom
software-mansion-labs:add-search-line-chart-component

Conversation

@mateuuszzzzz
Copy link
Contributor

@mateuuszzzzz mateuuszzzzz commented Jan 30, 2026

Explanation of Change

  • New LineChartContent with custom x-axis label rendering via Skia's
    renderOutside (right-anchored labels with edge clamping)
    • New SearchLineChart integrating the chart with search data, tooltips,
      and drill-down navigation
    • line option added to CONST.SEARCH.VIEW with translations in all
      languages
    • Refactored shared chart hooks (useChartLabelLayout,
      useChartInteractions, useTooltipData) and extracted utils.ts
    • Simplified BarChartContent and removed unused code (chartColors.ts,
      legacy constants)
    • Added @types/d3-scale to resolve Victory Native's Scale type, enabling
      proper typing for chart scale callbacks

Fixed Issues

$ #80802 #81025
PROPOSAL:

Tests

  • Render line chart with group-by: year | quarter | month | week and view:line
  • Hover over bar (web) - verify tooltip shows <category> • <amount> (<percentage>)
  • Click/tap on bar - verify drill-down navigation works correctly
  • Verify that labels are rendered correctly (no cut, readable etc.)

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

Same as tests

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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • 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 Screenshot 2026-02-04 at 16 40 09
Android: mWeb Chrome Screenshot 2026-02-04 at 16 42 31
iOS: Native Screenshot 2026-02-03 at 15 40 17
iOS: mWeb Safari Screenshot 2026-02-04 at 16 40 09
MacOS: Chrome / Safari Screenshot 2026-02-03 at 15 24 58

@melvin-bot
Copy link

melvin-bot bot commented Jan 30, 2026

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@mateuuszzzzz mateuuszzzzz marked this pull request as ready for review January 30, 2026 19:52
@mateuuszzzzz mateuuszzzzz requested review from a team as code owners January 30, 2026 19:52
@melvin-bot melvin-bot bot requested review from joekaufmanexpensify and removed request for a team January 30, 2026 19:52
@trjExpensify
Copy link
Contributor

Running translations. @ShridharGoel you can start reviewing!

@melvin-bot melvin-bot bot requested review from madmax330 and removed request for a team January 30, 2026 19:52
@melvin-bot
Copy link

melvin-bot bot commented Jan 30, 2026

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

@trjExpensify trjExpensify requested review from trjExpensify and removed request for joekaufmanexpensify and madmax330 January 30, 2026 19:52
@OSBotify
Copy link
Contributor

🦜 Polyglot Parrot! 🦜

Squawk! Looks like you added some shiny new English strings. Allow me to parrot them back to you in other tongues:

View the translation diff
diff --git a/src/languages/de.ts b/src/languages/de.ts
index 8da34128..db49434b 100644
--- a/src/languages/de.ts
+++ b/src/languages/de.ts
@@ -7079,7 +7079,7 @@ Fordere Spesendetails wie Belege und Beschreibungen an, lege Limits und Standard
             allMatchingItemsSelected: 'Alle passenden Elemente ausgewählt',
         },
         topSpenders: 'Top-Ausgaben',
-        view: {label: 'Ansehen', table: 'Tabelle', bar: 'Bar'},
+        view: {label: 'Ansehen', table: 'Tabelle', bar: 'Bar', line: 'Zeile', pie: 'Kreisdiagramm'},
         chartTitles: {
             [CONST.SEARCH.GROUP_BY.FROM]: 'Von',
             [CONST.SEARCH.GROUP_BY.CARD]: 'Karten',
diff --git a/src/languages/fr.ts b/src/languages/fr.ts
index 726c88e9..87b9ca26 100644
--- a/src/languages/fr.ts
+++ b/src/languages/fr.ts
@@ -7091,7 +7091,7 @@ Exigez des informations de dépense comme les reçus et les descriptions, défin
             allMatchingItemsSelected: 'Tous les éléments correspondants sont sélectionnés',
         },
         topSpenders: 'Plus gros dépensiers',
-        view: {label: 'Afficher', table: 'Tableau', bar: 'Barre'},
+        view: {label: 'Afficher', table: 'Tableau', bar: 'Barre', line: 'Ligne', pie: 'Secteur'},
         chartTitles: {
             [CONST.SEARCH.GROUP_BY.FROM]: 'De',
             [CONST.SEARCH.GROUP_BY.CARD]: 'Cartes',
diff --git a/src/languages/it.ts b/src/languages/it.ts
index 33c0428b..383ab295 100644
--- a/src/languages/it.ts
+++ b/src/languages/it.ts
@@ -7068,7 +7068,7 @@ Richiedi dettagli di spesa come ricevute e descrizioni, imposta limiti e valori
             allMatchingItemsSelected: 'Tutti gli elementi corrispondenti selezionati',
         },
         topSpenders: 'Maggiori spenditori',
-        view: {label: 'Visualizza', table: 'Tabella', bar: 'Bar'},
+        view: {label: 'Visualizza', table: 'Tabella', bar: 'Bar', line: 'Riga', pie: 'Torta'},
         chartTitles: {
             [CONST.SEARCH.GROUP_BY.FROM]: 'Da',
             [CONST.SEARCH.GROUP_BY.CARD]: 'Carte',
diff --git a/src/languages/ja.ts b/src/languages/ja.ts
index 761da272..687009ff 100644
--- a/src/languages/ja.ts
+++ b/src/languages/ja.ts
@@ -7006,7 +7006,7 @@ ${reportName}
             allMatchingItemsSelected: '一致する項目をすべて選択済み',
         },
         topSpenders: 'トップ支出者',
-        view: {label: '表示', table: 'テーブル', bar: 'バー'},
+        view: {label: '表示', table: 'テーブル', bar: 'バー', line: '行', pie: 'パイ'},
         chartTitles: {
             [CONST.SEARCH.GROUP_BY.FROM]: '差出人',
             [CONST.SEARCH.GROUP_BY.CARD]: 'カード',
diff --git a/src/languages/nl.ts b/src/languages/nl.ts
index f4f2720e..eb31092d 100644
--- a/src/languages/nl.ts
+++ b/src/languages/nl.ts
@@ -7051,7 +7051,7 @@ Vraag verplichte uitgavedetails zoals bonnetjes en beschrijvingen, stel limieten
             allMatchingItemsSelected: 'Alle overeenkomende items geselecteerd',
         },
         topSpenders: 'Grootste uitgaven',
-        view: {label: 'Bekijken', table: 'Tabel', bar: 'Bar'},
+        view: {label: 'Bekijken', table: 'Tabel', bar: 'Bar', line: 'Regel', pie: 'Taart'},
         chartTitles: {
             [CONST.SEARCH.GROUP_BY.FROM]: 'Van',
             [CONST.SEARCH.GROUP_BY.CARD]: 'Kaarten',
diff --git a/src/languages/pl.ts b/src/languages/pl.ts
index 7c790e38..2ca38c1c 100644
--- a/src/languages/pl.ts
+++ b/src/languages/pl.ts
@@ -7039,7 +7039,7 @@ Wymagaj szczegółów wydatków, takich jak paragony i opisy, ustawiaj limity i
             allMatchingItemsSelected: 'Wybrano wszystkie pasujące elementy',
         },
         topSpenders: 'Najwięksi wydający',
-        view: {label: 'Zobacz', table: 'Tabela', bar: 'Pasek'},
+        view: {label: 'Zobacz', table: 'Tabela', bar: 'Pasek', line: 'Linia', pie: 'Ciasto'},
         chartTitles: {
             [CONST.SEARCH.GROUP_BY.FROM]: 'Od',
             [CONST.SEARCH.GROUP_BY.CARD]: 'Karty',
diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts
index 84ec5415..9fbbe9ee 100644
--- a/src/languages/pt-BR.ts
+++ b/src/languages/pt-BR.ts
@@ -7040,7 +7040,7 @@ Exija detalhes de despesas como recibos e descrições, defina limites e padrõe
             allMatchingItemsSelected: 'Todos os itens correspondentes selecionados',
         },
         topSpenders: 'Maiores gastadores',
-        view: {label: 'Ver', table: 'Tabela', bar: 'Bar'},
+        view: {label: 'Ver', table: 'Tabela', bar: 'Bar', line: 'Linha', pie: 'Pizza'},
         chartTitles: {
             [CONST.SEARCH.GROUP_BY.FROM]: 'De',
             [CONST.SEARCH.GROUP_BY.CARD]: 'Cartões',
diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts
index 7630d11c..aa3e9ad9 100644
--- a/src/languages/zh-hans.ts
+++ b/src/languages/zh-hans.ts
@@ -6886,7 +6886,7 @@ ${reportName}
             allMatchingItemsSelected: '已选择所有匹配的项目',
         },
         topSpenders: '最高支出者',
-        view: {label: '查看', table: '表格', bar: '栏'},
+        view: {label: '查看', table: '表格', bar: '栏', line: '行', pie: '派'},
         chartTitles: {
             [CONST.SEARCH.GROUP_BY.FROM]: '来自',
             [CONST.SEARCH.GROUP_BY.CARD]: '卡片',

Note

You can apply these changes to your branch by copying the patch to your clipboard, then running pbpaste | git apply 😉

View workflow run

@github-actions
Copy link
Contributor

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

@trjExpensify
Copy link
Contributor

CC: @dannymcclain

@github-actions

This comment has been minimized.

Copy link

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

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: a8c40b2c02

ℹ️ 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".

@ShridharGoel
Copy link
Contributor

Bug: Negative values are above the X-axis and the Y-axis isn't starting from 0.

Screenshot 2026-01-31 at 1 38 27 AM

@mateuuszzzzz
Copy link
Contributor Author

mateuuszzzzz commented Feb 5, 2026

LineChart's labels should be centered now

Screenshot 2026-02-05 at 11 24 06

@mateuuszzzzz
Copy link
Contributor Author

Also I addressed this default sort order cc: @trjExpensify

@shawnborton
Copy link
Contributor

Can we get a little breathing room under the chart though? Like maybe at least an 8px gap from bottom of chart to the labels? It feels a bit squished right now:
CleanShot 2026-02-05 at 11 27 40@2x

@mateuuszzzzz
Copy link
Contributor Author

Can we get a little breathing room under the chart though? Like maybe at least an 8px gap from bottom of chart to the labels? It feels a bit squished right now:

Done 👌

@shawnborton
Copy link
Contributor

Thanks - screenshot please?

@mateuuszzzzz
Copy link
Contributor Author

Thanks - screenshot please?

Right! 😅

Screenshot 2026-02-05 at 15 18 51

@trjExpensify
Copy link
Contributor

Happy with that, @shawnborton?

Copy link
Contributor

@lakchote lakchote left a comment

Choose a reason for hiding this comment

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

Nice work, LGTM

Copy link
Contributor

@trjExpensify trjExpensify left a comment

Choose a reason for hiding this comment

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

Re-approving. Core PR for a WN project. 👍

barCount={barCount}
innerPadding={BAR_INNER_PADDING}
roundedCorners={BAR_ROUNDED_CORNERS}
roundedCorners={{topLeft: 8, topRight: 8, bottomLeft: 8, bottomRight: 8}}
Copy link
Contributor

Choose a reason for hiding this comment

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

nab: why are these no longer constants?

@puneetlath puneetlath merged commit f939855 into Expensify:main Feb 5, 2026
41 checks passed
@shawnborton
Copy link
Contributor

Not quite. Can we use the same amount of space we see on the left?
CleanShot 2026-02-05 at 18 28 14@2x

We can do it as a follow up. But ideally there would be equal margin on the left side and the bottom side. Curious if @Expensify/design agrees!

@OSBotify
Copy link
Contributor

OSBotify commented Feb 5, 2026

🚀 Deployed to staging by https://github.com/puneetlath in version: 9.3.13-1 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Feb 5, 2026

🚀 Deployed to staging by https://github.com/puneetlath in version: 9.3.15-0 🚀

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

@dubielzyk-expensify
Copy link
Contributor

I dig the green if we always default to the same starting color for single line charts. Curious what @Expensify/design thinks about that one.

We deliberately didn't chose green because we use green throughout the app and it's used for things like actions and GBRs, so we thought blue was a better to ensure it's viewed as content. Same reason why our bar graphs don't lead with green as a color. Curious what @dannymcclain thinks.

We can do it as a follow up. But ideally there would be equal margin on the left side and the bottom side. Curious if @Expensify/design agrees!

Yeah definitely agree

@shawnborton
Copy link
Contributor

Oh interesting, I could see that making sense - sorry for the bad suggestion, we can fix in a follow up.

@jponikarchuk
Copy link

@mateuuszzzzz @trjExpensify @ShridharGoel Could you please confirm if you are interested in fixing such an issue:

Expense - In view:line chart, month is not displayed correctly in Chinese/Japanese language.

Action Performed:

  1. Launch app
  2. Open workpace chat
  3. Create a manual expense
  4. Go to reports
  5. Enter view:line
  6. Change app language to chinese/japanese
  7. Go to reports again
  8. Note month display in x axis

Expected Result:

In view:line chart, month must be displayed correctly in Chinese/Japanese language.

Actual Result:

In view:line chart, month is not displayed correctly in Chinese/Japanese language.

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

1.mp4

@IuliiaHerets
Copy link

Hi @lakchote @puneetlath. Can you please take a look at this?

Could you please confirm if you are interested in fixing such an issue

@dannymcclain
Copy link
Contributor

Agree with you both about the spacing! Also yes, I still think it's wise to not lead with green for these—too many other implications with the rest of our app haha.

@trjExpensify
Copy link
Contributor

Yeah @jponikarchuk, but it can be a follow-up and not a blocker. @mateuuszzzzz looks like a similar issue we saw to the rupees currency code one. Created an issue for you here: #81926

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.3.15-10 🚀

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

Comment on lines 84 to +85
const horizontalPadding = calculateMinDomainPadding(chartWidth, data.length, BAR_INNER_PADDING);
return {left: horizontalPadding, right: horizontalPadding + DOMAIN_PADDING.right, top: DOMAIN_PADDING.top, bottom: DOMAIN_PADDING.bottom};
return {...BASE_DOMAIN_PADDING, left: horizontalPadding, right: horizontalPadding};
Copy link
Contributor

Choose a reason for hiding this comment

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

There's edge case where data point is still cut off.
Fixed later in #81669

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.