question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Labels disappear from Bar when page is resized using a ResponsiveContainer

See original GitHub issue

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

When resizing a window, the ResponsiveContainer re-renders as expected, but the labels (and LabelLists) disappear.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: http://jsfiddle.net/ndLhnegs/).

The fiddle template didn’t work btw <ResponsiveContainer width="100%" height={500}> <BarChart margin={{ top: 20, right: 20, left: 20, bottom: 20 }} data={[{ name: 100, value: 12 }]}> <Tooltip /> <XAxis dataKey="name" /> <YAxis /> <Bar type="monotone" dataKey="value" fill="#1a8cd8" barSize={100}> <LabelList dataKey="name" position="top" /> </Bar> </BarChart> </ResponsiveContainer>

What is the expected behavior?

The labels don’t disappear

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

Windows Chrome Version 72.0.3626.121 (Official Build) (64-bit) “recharts”: “^1.5.0”,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:17

github_iconTop GitHub Comments

23reactions
yarv-devcommented, Jan 31, 2021

I added interval={0} to the x-axis and it resolved the issue for me <XAxis interval={0} />

8reactions
redbmkcommented, Mar 13, 2020

@xile611 I believe this is still a bug unless it was just fixed very recently, but I don’t see this issue mentioned in a PR or anything.

From what I can tell, the default Text element has some bug that causes state.width to go to 0 on resize.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rechart Responsive container does not render - Stack Overflow
For anybody rendering the chart inside a react-bootstrap component, don't use the ResponsiveContainer tag. you can simple use the logic ...
Read more >
10 Practical CSS Tricks every developer should know - Flexiple
CSS Trick #8 – Resize Image. Once we have dealt with resizing our page, we need to be able to resize our images....
Read more >
ResponsiveContainer | Recharts
A container component to make charts adapt to the size of parent container. One of the props width and height should be a...
Read more >
jQuery.floatThead
Floats the table header - so that the user can always see it; Supports tables with inner scroll bars, or window scrolling; Horizontal...
Read more >
Changelogs | Docs - Developer - SEMrush
Bar component now supports onClick handler with bar data in callback. ... Export of NoticeBubbleManager was missing in typings.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found