Skip to content

Separate TreemapItem component and fix animation in Treemap#6326

Merged
ckifer merged 1 commit intomainfrom
treemap-animation-fix
Sep 16, 2025
Merged

Separate TreemapItem component and fix animation in Treemap#6326
ckifer merged 1 commit intomainfrom
treemap-animation-fix

Conversation

@PavelVanecek
Copy link
Collaborator

Description

I never really understood the Treemap animation and now I see why, it was a transition from (random X, random Y). No wonder it felt random. So I switched it into a "slide from left" animation, at least it's now stable. We can experiment with other animations, I couldn't quickly find anything that feels amazing.

Related Issue

Fixes #6310

Also 387 errors -> 377 for #5768

How Has This Been Tested?

Storybook, VR

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

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 refactors the Treemap component to separate the item rendering logic into a standalone TreemapItem component and fixes the animation behavior by replacing random positioning with a consistent "slide from left" animation.

Key changes:

  • Extracted TreemapItem as a separate functional component to improve code organization
  • Replaced random animation positioning with a stable left-to-right slide animation
  • Simplified event handling by moving mouse and click handlers into the new component

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

const name: string = get(item, nameKey as string, 'root');
let content: ReactNode = null;
if (React.isValidElement(nestIndexContent)) {
// the cloned content is ignored at all times - let's remove it?
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

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

This TODO comment suggests uncertainty about the code's purpose. Either remove the comment if the cloned content is indeed unused, or provide clearer documentation explaining why the cloning is necessary and when the content might be used.

Suggested change
// the cloned content is ignored at all times - let's remove it?
// Clone the nestIndexContent element, passing the current item and index as props.

Copilot uses AI. Check for mistakes.
nodeProps={{
...nodeProps,
isAnimationActive,
isUpdateAnimationActive: !isUpdateAnimationActive,
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

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

The logic !isUpdateAnimationActive appears incorrect. If isUpdateAnimationActive is true, this would set the property to false, which seems counterintuitive. This should likely be just isUpdateAnimationActive without negation.

Suggested change
isUpdateAnimationActive: !isUpdateAnimationActive,
isUpdateAnimationActive: isUpdateAnimationActive,

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

True - reads kinda confusing

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 there before 😬 I can change that but it will start animating the Rectangle borders too.

Copy link
Member

Choose a reason for hiding this comment

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

Don't want that I don't think

@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

❌ Patch coverage is 96.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.65%. Comparing base (3985391) to head (f6c14a3).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/chart/Treemap.tsx 96.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6326      +/-   ##
==========================================
- Coverage   96.66%   96.65%   -0.02%     
==========================================
  Files         221      221              
  Lines       20352    20345       -7     
  Branches     4173     4171       -2     
==========================================
- Hits        19674    19665       -9     
- Misses        671      673       +2     
  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 Sep 16, 2025

Bundle Report

Changes will decrease total bundle size by 804 bytes (-0.03%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.05MB -244 bytes (-0.02%) ⬇️
recharts/bundle-es6 902.69kB -248 bytes (-0.03%) ⬇️
recharts/bundle-umd 487.57kB -312 bytes (-0.06%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js -312 bytes 487.57kB -0.06%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
chart/Treemap.js -248 bytes 25.63kB -0.96%
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
chart/Treemap.js -244 bytes 27.2kB -0.89%

@ckifer ckifer merged commit 7e841c4 into main Sep 16, 2025
25 of 27 checks passed
@ckifer ckifer deleted the treemap-animation-fix branch September 16, 2025 15:22
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.

3.2.0 Broken Treemap Rendering

3 participants