Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CSS transition for sectors on hover in PieChart with isAnimationActive as true #4216

Open
1 task done
beltranrengifo opened this issue Feb 21, 2024 · 3 comments
Open
1 task done
Labels
bug General bug label enhancement Enhancement to a current API

Comments

@beltranrengifo
Copy link

beltranrengifo commented Feb 21, 2024

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  • if isAnimationActive is true, hover any sector, check the fill transition is not applied
  • if isAnimationActive is false, hover any sector, check the fill transition is applied

What is expected?

the fill transition works in both cases

What is actually happening?

the fill transition only works if isAnimationActive is false

Environment Info
Recharts v2.12.1
React 16.14.0
System 14.3 (23D56)
Browser Chrome Version 121.0.6167.184 (Official Build) (arm64)

I posted this in SO as I thought it was not an issue but I got no response so I'm opening this here. Thank you!

@ckifer ckifer added bug General bug label enhancement Enhancement to a current API labels Feb 21, 2024
@ckifer
Copy link
Member

ckifer commented Feb 21, 2024

Looks like this is a bug as far as I can tell. When animation is not active, the sectors do not re-render on hover. When animation is active, they do. Probably a rendering optimization to be done here.

@beltranrengifo
Copy link
Author

beltranrengifo commented Feb 21, 2024

Looks like this is a bug as far as I can tell. When animation is not active, the sectors do not re-render on hover. When animation is active, they do. Probably a rendering optimization to be done here.

Thanks for your inputs @ckifer
Let me know how I can help, in case this is a bug suitable for new people in this repo 🙌

@ckifer
Copy link
Member

ckifer commented Feb 21, 2024

https://github.com/recharts/recharts/blob/3.x/src/polar/Pie.tsx#L536

This is probably where the issue is, but the fix isn't clear. I personally wouldn't recommend this as a first issue to take up, but feel free to look into it if you'd like

ckifer pushed a commit that referenced this issue May 15, 2024
## Description

This PR is for the issue with `PieChart` that custom animations do not
work when `isAnimationActive` is set to true

## Related Issue

[Enable CSS transition for sectors on hover in PieChart with
isAnimationActive as
true](#4216)

## Motivation and Context

After digging into the code, I found that the `key` in the `Animate`
component causes the problem. The dynamic key triggers the process of
remounting the component, which overrides the custom animation. It also
adds rendering burden: if a user sets the mouse hover animation, every
time the user hovers over one piece of the pie chart, the entire pie
chart will re-render.

## How Has This Been Tested?

Tested locally

## Screenshots (if appropriate):


https://github.com/recharts/recharts/assets/41566276/f9662c73-8985-4c85-9b78-af8d91dc7b2a


## Types of changes

- [x] 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)

## Checklist:

- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] I have added a storybook story or extended an existing story to
show my changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug General bug label enhancement Enhancement to a current API
Projects
None yet
Development

No branches or pull requests

2 participants