Labels disappear from Bar when page is resized using a ResponsiveContainer
See original GitHub issueDo 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:
- Created 5 years ago
- Reactions:15
- Comments:17
Top GitHub Comments
I added interval={0} to the x-axis and it resolved the issue for me <XAxis interval={0} />
@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 causesstate.width
to go to 0 on resize.