Skip to content

[NoQA][Insights Polish] Update line chart's line, points and hover - #103050

Merged
cristipaval merged 9 commits into
Expensify:mainfrom
software-mansion-labs:olgierd/insights-line-chart-polish
Oct 6, 2026
Merged

cristipaval merged 9 commits into
Expensify:mainfrom
software-mansion-labs:olgierd/insights-line-chart-polish

Conversation

@OlGierd03

@OlGierd03 OlGierd03 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The Spend over time line is now 4px wide with rounded ends, and it no longer draws dots at rest. Hovering anywhere in a period's full-height column shows the tooltip, a dot on the line and a vertical guideline. Before, the cursor had to be over the dot itself.

The dot and the guideline are drawn by the new ActivePointIndicator, which reads the hovered point from a new activePointPosition value returned by useChartInteractions. Because of this, hovering doesn't re-render the chart. ScatterPoints is removed, since the line chart was its only consumer.

Fixed Issues

$ #102862

Tests

Precondition: account with the insightsPage beta and expenses in at least a few months of the current year.

  1. Open the Insights tab.
  2. On Spend over time, verify the line is 4px wide with rounded ends and no dots are drawn on it.
  3. Hover a data point and verify the tooltip, a dot on the line and a vertical guideline appear.
  4. Hover empty space above and below the line in the same column and verify the same tooltip, dot and guideline show.
  5. Move the cursor horizontally across the chart and verify the dot and guideline follow each period.
  6. Move the cursor off the chart and verify the dot and guideline disappear without leaving a gap in the line.
  7. Click empty space in a column and verify the Spend page opens filtered to that period.
  8. Switch to dark mode and repeat steps 2–6.
  9. Open a Spend search with view:line and repeat steps 2–7.

Offline tests

N/A

QA Steps

NoQA

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

MacOS: Chrome / Safari Screenshot 2026-10-06 at 17 17 27
Screen.Recording.2026-10-06.at.17.15.43.mov

@OlGierd03 OlGierd03 closed this Oct 5, 2026
@OlGierd03
OlGierd03 deleted the olgierd/insights-line-chart-polish branch October 5, 2026 14:36
@OlGierd03
OlGierd03 restored the olgierd/insights-line-chart-polish branch October 5, 2026 14:58
@OlGierd03 OlGierd03 reopened this Oct 5, 2026
@OlGierd03
OlGierd03 marked this pull request as ready for review October 5, 2026 15:57
@OlGierd03
OlGierd03 requested review from a team as code owners October 5, 2026 15:57
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and truph01 and removed request for a team October 5, 2026 15:57
@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]

@OlGierd03

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@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/VictoryTheme.ts 100.00% <ø> (ø)
...rc/components/Charts/hooks/useChartInteractions.ts 47.50% <ø> (+0.39%) ⬆️
...ponents/Charts/components/ActivePointIndicator.tsx 9.09% <9.09%> (ø)
...c/components/Charts/LineChart/LineChartContent.tsx 0.00% <0.00%> (-3.66%) ⬇️
... and 54 files with indirect coverage changes

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The approach looks good. Reading the hovered point from shared values keeps hover off the JS thread, and moving the line constants into VictoryTheme.line is clean. CI is green except for the approval check. I found one bug and two nits.

🐛 Hover stops working when the chart has one data point

LineChartContent.tsx:158 uses the plotAreaWidth state as the band width when data.length === 1. That value is stale on first mount:

  1. victory-native runs its onChartBoundsChange and onScaleChange effects in the same commit.
  2. setPlotAreaWidth hasn't re-rendered yet, so handleScaleChange sees plotAreaWidth = 0 and sets bandHalfWidth to 0.
  3. onScaleChange only fires again when the scale's domain or range changes. With one point, nothing changes after the re-render, so bandHalfWidth stays 0.

checkIsOverBand then matches only when cursorX === targetX exactly. Hovering or clicking the plot does nothing. Only the x-axis label still works. You'd see this on Spend over time, or a view:line search, that has spend in only one period.

Fix: read the width from the scale instead of React state, for example:

const [rangeStart, rangeEnd] = xScale.range();
bandHalfWidth.set(data.length > 1 ? Math.abs(xScale(1) - xScale(0)) / 2 : Math.abs(rangeEnd - rangeStart));

With one point, any x in the plot belongs to it, so the full range width is the correct band.

Nits

  • ActivePointIndicator.tsx:10-21: isActive, dotRadius, dotColor and guidelineColor have no JSDoc. The other props in this file have it, and so did the removed ScatterPoints.
  • SelectFeaturesEmptyTagGroupTest.tsx:115: the global.fetch mock has nothing to do with the chart change. If it fixes a failure that is also on main, a separate PR or a note in the description would help reviewers.

view run

@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 previously approved these changes Oct 5, 2026

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

This is looking really great. Going to approve! This is ready to be reviewed by C+, though let's make sure that we get design feedback before merging.

@dannymcclain

Copy link
Copy Markdown
Contributor

Looking so good!

Tiny nitpick: can we make the "guide" line use our green-400 color at 20% opacity?

CleanShot 2026-10-05 at 4 03 08 PM@2x CleanShot 2026-10-05 at 4 03 03 PM@2x

Example from Figma:
CleanShot 2026-10-05 at 4 04 31 PM@2x

@dannymcclain

Copy link
Copy Markdown
Contributor

Oops one more super duper nitpick: is it possible to make the hover dot on the very first item sit over top the axis so it doesn't get clipped?

CleanShot 2026-10-05 at 4 06 33 PM@2x CleanShot 2026-10-05 at 4 06 25 PM@2x

@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.10.12.42.mov
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-10-06.at.10.08.16.mov

const dx = args.cursorX - args.targetX;
const dy = args.cursorY - args.targetY;
return Math.sqrt(dx * dx + dy * dy) <= DOT_RADIUS + DOT_HOVER_EXTRA_RADIUS;
return Math.abs(args.cursorX - args.targetX) <= bandHalfWidth.get() && args.cursorY >= plotTop.get() && args.cursorY <= args.chartBottom;

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.

Band leaks into the y-axis label area

The first point's band extends bandHalfWidth left of bounds.left, so hovering/clicking the y-axis labels shows the tooltip and navigates to the first period.

Should we also clamp cursorX to the plot's left/right bounds here?

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should we also clamp cursorX to the plot's left/right bounds here?

Not sure

@OlGierd03

Copy link
Copy Markdown
Contributor Author

Tiny nitpick: can we make the "guide" line use our green-400 color at 20% opacity?

Oops one more super duper nitpick: is it possible to make the hover dot on the very first item sit over top the axis so it doesn't get clipped?

@dannymcclain thanks for the catches! Both done. Will update PR description with new screenshots after addressing other review comments

@OlGierd03

Copy link
Copy Markdown
Contributor Author

Hover stops working when the chart has one data point

In practice, the issue doesn't reproduce, but it's true that the current implementation is prone to this bug. I've applied the suggested change.

ActivePointIndicator.tsx:10-21: isActive, dotRadius, dotColor and guidelineColor have no JSDoc. The other props in this file have it, and so did the removed ScatterPoints.

I didn't add any JSDoc comments to these props because I figured their names were self-explanatory.

SelectFeaturesEmptyTagGroupTest.tsx:115: the global.fetch mock has nothing to do with the chart change. If it fixes a failure that is also on main, a separate PR or a note in the description would help reviewers.

True, the change is not really directly related. Reverted!

@OlGierd03

Copy link
Copy Markdown
Contributor Author

@JmillsExpensify @Expensify/design I've got a question that came from @truph01. Should hovering near the side edges of the chart still highlight the first/last point?

Right now each point has a hover band centered on it, so for the first and last points band sticks out past the plot area. On one hand there's no chart there anymore, so catching the point feels a little unexpected. On the other hand it feels kind of intuitive to me that the hover is not only on one side of the point.

Right now it looks like this:

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

@dannymcclain

Copy link
Copy Markdown
Contributor

Yeah it does feel a little unexpected for the far right one when you're hovering over the Y-Axis. But tbh I don't hate it. Curious for @JmillsExpensify's take. Do y'all think it'd be better to limit the hover areas to be contained within the plot area, basically within this red rectangle?

CleanShot 2026-10-06 at 8 57 39 AM@2x

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Yeah it does feel a little unexpected for the far right one when you're hovering over the Y-Axis. But tbh I don't hate it. Curious for @JmillsExpensify's take. Do y'all think it'd be better to limit the hover areas to be contained within the plot area, basically within this red rectangle?

CleanShot 2026-10-06 at 8 57 39 AM@2x

Yeah, I think it would be ideal to limit the hover areas to be contained within the plot area. We can also merge though and address it later. Depends on if @OlGierd03 is still online for the day.

@OlGierd03

Copy link
Copy Markdown
Contributor Author

I am and I'm on it. The change should be ready in a few minutes

@OlGierd03

OlGierd03 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@JmillsExpensify @dannymcclain I've applied the changes, so the hover should now work as expected. I've also updated the video and the screenshot in the PR description. It shows how the hover area looks like now.

Mentioned video:

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

@JmillsExpensify

Copy link
Copy Markdown
Contributor

That looks great. @dannymcclain you good?

@truph01

truph01 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

It looks good now:

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

@dannymcclain

Copy link
Copy Markdown
Contributor

Yeah that looks good to me!

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

@cristipaval
cristipaval merged commit f7ec41c 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

🚧 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 changes how the Spend over time line chart looks and responds to hover (thicker line, no resting dots, column-wide hover). No article under docs/articles describes the chart's dots or how to hover over data points, so no existing sentence is now wrong.


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.

9 participants