#7875·recharts

Legend overlaps x-axis after being measured inside a scaled parent

Author: alexandr-planableCreated Sep 29, 2026Updated Sep 29, 2026

What is the current behavior?

Since 3.9 (#7201) the legend re-measures itself in a ResizeObserver using getBoundingClientRect(). If a parent has a CSS transform at that moment, it stores the scaled size. Removing the transform doesn't trigger the observer again, so the chart keeps reserving too little space and the legend ends up on top of the x-axis labels.

We hit it with motion layout animations (the card scales while the chart loads).

3.10.1 3.8.1
3.10.1 3.8.1

What is the expected behavior?

Once the transform is gone, the chart reserves the legend's real size, like it does in 3.8.1.

Please provide a demo of the problem in a sandbox

https://stackblitz.com/edit/tvsrdhzo-t2kf7pcs?file=src%2FExample.tsx

Click "Resize while scaled".

Reading the size from the ResizeObserver entry (entries[0].borderBoxSize) fixes it. Happy to open a PR.

Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?

3.9.0 and later (tested 3.10.1). Works in 3.8.1. React 18.2 and 19, Chrome, macOS.