Skip to content

Fix Axis blinking when changing props, and YAxis width=auto wrapping#6262

Merged
PavelVanecek merged 4 commits intomainfrom
axis-blink
Sep 7, 2025
Merged

Fix Axis blinking when changing props, and YAxis width=auto wrapping#6262
PavelVanecek merged 4 commits intomainfrom
axis-blink

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Aug 30, 2025

Description

Remove the return null that makes the XAxis disappear in Chrome on weak hardware (or 4x CPU slowdown)

More findings

Okay so once I fixed the blink, the text started wrapping with width=auto. I can fix that by excluding the axis width from tick props if width=auto (because in that case we want the Text to calculate its own width, and push it up to the axis). That creates visual diff elsewhere but that looks more like a bugfix to me so I will do that.

Related Issue

Fixes #6257

Copilot AI review requested due to automatic review settings August 30, 2025 03:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a blinking issue in XAxis and YAxis components that occurred on weak hardware in Chrome by removing early returns that caused components to disappear during prop synchronization. The fix ensures axis components use synchronized settings from the Redux store rather than component props to prevent render inconsistencies.

Key changes:

  • Removes conditional returns that caused axis blinking during prop changes
  • Updates axis components to use synchronized settings from the store
  • Adjusts test expectations to reflect the additional render call

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/cartesian/XAxis.tsx Removes early return logic and adds synchronized settings usage to prevent blinking
src/cartesian/YAxis.tsx Adds synchronized settings usage and updates null check condition
test/chart/LineChart.spec.tsx Updates test expectations from 3 to 4 axis render calls
test/chart/AreaChart.spec.tsx Updates test expectations from 3 to 4 axis render calls

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Aug 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.63%. Comparing base (bbb344e) to head (2df4a5b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6262   +/-   ##
=======================================
  Coverage   96.62%   96.63%           
=======================================
  Files         221      221           
  Lines       20182    20195   +13     
  Branches     4140     4145    +5     
=======================================
+ Hits        19501    19515   +14     
+ Misses        674      673    -1     
  Partials        7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov
Copy link

codecov bot commented Aug 30, 2025

Bundle Report

Changes will increase total bundle size by 3.9kB (0.16%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.04MB 1.96kB (0.19%) ⬆️
recharts/bundle-es6 899.15kB 1.76kB (0.2%) ⬆️
recharts/bundle-umd 487.77kB 192 bytes (0.04%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 192 bytes 487.77kB 0.04%
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
state/selectors/axisSelectors.js 452 bytes 59.06kB 0.77%
cartesian/CartesianAxis.js 93 bytes 14.29kB 0.66%
cartesian/YAxis.js 908 bytes 9.78kB 10.23% ⚠️
cartesian/XAxis.js 502 bytes 7.65kB 7.02% ⚠️
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
state/selectors/axisSelectors.js 244 bytes 49.56kB 0.49%
cartesian/CartesianAxis.js 93 bytes 13.12kB 0.71%
cartesian/YAxis.js 907 bytes 8.58kB 11.83% ⚠️
cartesian/XAxis.js 512 bytes 6.51kB 8.53% ⚠️

@ckifer
Copy link
Member

ckifer commented Aug 30, 2025

Huh, that's pretty wild

@PavelVanecek
Copy link
Collaborator Author

There's something wrong with Text wrapping. Let's wait with merging this before I figure it out.

@ckifer
Copy link
Member

ckifer commented Aug 30, 2025

Sounds good

PavelVanecek added a commit that referenced this pull request Sep 5, 2025
## Description

Just tests, no changes.

## Related Issue

I want to have baseline to debug the regression from
#6262
@PavelVanecek PavelVanecek changed the title Fix Axis blinking when changing props Fix Axis blinking when changing props, and YAxis width=auto wrapping Sep 7, 2025
if (settingsAreSynchronized) {
return props.children;
}
return null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was the "blink"

scale={scale}
x={position.x}
y={position.y}
tickTextProps={width === 'auto' ? { width: undefined } : { width }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If width is auto then we need to let Text calculate its own width, so we overwrite whatever width is coming from the axisProps

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have some visual diff in the PR.

This source code is:

<YAxis width="auto" tickFormatter={value => `Long Long Y tick: ${value}`} />

I think it's an improvement - I would expect width=auto to show ticks unwrapped. Or should we prefer one word per line?

Copy link
Member

Choose a reason for hiding this comment

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

I think unwrapped by default but there were some people talking about this I think. It makes width auto hard to use when you have long ticks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

<YAxis width="auto" tick={{ fontSize: 9 }} tickFormatter={value => `Long Long Y tick: ${value}`} />

Same as above, I consider this an improvement

@PavelVanecek
Copy link
Collaborator Author

What still doesn't work is maxLines on the ticks. The prop is right there but doesn't do anything. I don't recall anyone complaining about it though.

@ckifer
Copy link
Member

ckifer commented Sep 7, 2025

It doesn't work pre this either?

@PavelVanecek
Copy link
Collaborator Author

No it ignores the prop always. Before this PR it always wraps, after it never wraps. (With width auto)

@PavelVanecek PavelVanecek merged commit 44c78d3 into main Sep 7, 2025
27 checks passed
@PavelVanecek PavelVanecek deleted the axis-blink branch September 7, 2025 14:50
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.

LegendEffectOpacity story causes X-Axis to 'blink'

3 participants