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

The chart shrinks when I apply a larger scale on it's parent container #4246

Labels
pending response Pending response from the issue requester

Comments

@zhonglin94
Copy link

Hi Recharts experts!

The chart shrinks when I apply a larger scale on the parent container. The following is a video demonstrating the issue.

Thank you so much if you could take a look and give me some suggestions!

2024-02-29.7.32.28.mov
@ckifer
Copy link
Member

ckifer commented Feb 29, 2024

It looks like things are just adjusting from the margin on the chart. You could try reducing margin on the fly maybe or starting off with less?

@ckifer ckifer added the pending response Pending response from the issue requester label Mar 1, 2024
@zhonglin94
Copy link
Author

It looks like things are just adjusting from the margin on the chart. You could try reducing margin on the fly maybe or starting off with less?

Hi Ckifer, I did not see any margin that has been applied to the chart when I adjust the parent container's scale. I can reproduce this in the recharts official website.

2024-03-01.6.38.14.1.mov

@ckifer ckifer removed the pending response Pending response from the issue requester label Mar 1, 2024
@ckifer
Copy link
Member

ckifer commented Mar 1, 2024

These things do not look the same. Here with scale or transform: scale there is no movement in the chart size and the margin of the chart is unchanged. This is correct behavior.

The first video is different than the second - what are you using for scale in the first video?

@ckifer ckifer added the pending response Pending response from the issue requester label Mar 1, 2024
@zhonglin94
Copy link
Author

These things do not look the same. Here with scale or transform: scale there is no movement in the chart size and the margin of the chart is unchanged. This is correct behavior.

The first video is different than the second - what are you using for scale in the first video?

The chart is placed inside the react flow's node and the transform of react flow view port is "transform: translate(-3447.32px, -1646.51px) scale(2.85055)" for example.

@ckifer ckifer removed the pending response Pending response from the issue requester label Mar 4, 2024
@ckifer
Copy link
Member

ckifer commented Mar 4, 2024

transform: scale works on the recharts website and other places I've checked without moving the axis.

Are you positive that you aren't dynamically changing chart margin based upon the scale yourself? I can't see any other reason why it would move like that

recharts-transform-scale.mov

@ckifer
Copy link
Member

ckifer commented Mar 4, 2024

Unless you are using an old version of recharts, which may have this issue

@ckifer ckifer added the pending response Pending response from the issue requester label Mar 4, 2024
@RrYusheng
Copy link

I set the composedchart prop like this:
code
but it seems still not working properly:
image

@RrYusheng
Copy link

looks like Yaxis is been compressed

@ckifer
Copy link
Member

ckifer commented Mar 5, 2024

You have static heights and widths on some of your components, those might be causing issues. Both grid and YAxis shouldn't have a width/height

@zhonglin94
Copy link
Author

zhonglin94 commented Mar 8, 2024

Unless you are using an old version of recharts, which may have this issue

Hi Ckifer, I think that I have found the root cause for this issue: the legend size(height and width) provided by the getBoundingClientRects is changed if it's parent container is transformed using scale. If the container scale is 3x, then the legend height is significantly larger than usual, which makes the chart content visibly smaller than expected.

Consequently, I propose to fix this issue as following:
截屏2024-03-08 下午11 10 19

@ckifer
Copy link
Member

ckifer commented Mar 8, 2024

Thanks for the find - makes sense since I was testing without Legend. Please feel free to contribute the fix if you'd like!

@zhonglin94 zhonglin94 mentioned this issue Mar 9, 2024
9 tasks
@ckifer
Copy link
Member

ckifer commented Mar 15, 2024

released in 2.12.3

@ckifer ckifer closed this as completed Mar 15, 2024
renovate bot added a commit to SAP/ui5-webcomponents-react that referenced this issue Mar 18, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [recharts](https://togithub.com/recharts/recharts) | [`2.12.2` ->
`2.12.3`](https://renovatebot.com/diffs/npm/recharts/2.12.2/2.12.3) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/recharts/2.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/recharts/2.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/recharts/2.12.2/2.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/recharts/2.12.2/2.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>recharts/recharts (recharts)</summary>

###
[`v2.12.3`](https://togithub.com/recharts/recharts/releases/tag/v2.12.3)

[Compare
Source](https://togithub.com/recharts/recharts/compare/v2.12.2...v2.12.3)

Some more small changes/fixes while working on 3.x

#### What's Changed

##### Fix

- `Legend`: fix issue where Legend was not taken into account when
scaling the chart container by
[@&#8203;zhonglin94](https://togithub.com/zhonglin94) in
[recharts/recharts#4272
closes
[recharts/recharts#4246
- `Area`: fixed a bug where className was not assigned to areaDot by
[@&#8203;108yen](https://togithub.com/108yen) in
[recharts/recharts#4294
closes
[recharts/recharts#4290
- `RadialBar`: address regression where radial bar and its background
were off from eachother because of rounding by
[@&#8203;ckifer](https://togithub.com/ckifer) in
[recharts/recharts#4295
closes
[recharts/recharts#4264
- `ErrorBar`: do not count `null` as 0 in error bar domain by
[@&#8203;rinkstiekema](https://togithub.com/rinkstiekema) in
[recharts/recharts#4297

#### New Contributors

- [@&#8203;zhonglin94](https://togithub.com/zhonglin94) made their first
contribution in
[recharts/recharts#4272

**Full Changelog**:
recharts/recharts@v2.12.2...v2.12.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/SAP/ui5-webcomponents-react).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI0NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment