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.

ResponsiveContainer not resizing

See original GitHub issue

Hey guys,

I’m currently building an app for a NGO and i’m using Recharts. So far it looks great however when I try to go into responsive mode the charts won’t resize.

Code I’m using:

Where it is rendered:

` <div className="row">

                <div className=" col-md-6 col-sm-12 col-xs-12">

                       <Chart />

                </div>

            </div>

`

And the component itself: ` <div style={{height:‘300px’, width: ‘600px’}}>

            <ResponsiveContainer width="100%">
                    <BarChart data={data}
                        margin={{ top: 5, right: 30, left: 20, bottom: 5 }}>
                        <XAxis dataKey="estadoCivil" />
                        <YAxis />  
                        <CartesianGrid strokeDasharray="3 3" />
                        <Tooltip />
                        <Legend />
                        <Bar dataKey="cantidad" fill="#8884d8" />
                    </BarChart>
            </ResponsiveContainer>
         </div>`

I’m using React 16.0 and Recharts 1.0.0

I’ve tried a few solutions I found online but none is working so far. My lastest attempt was wrapping the component inside a div with fixed height and width just as a test, but still not working.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

2reactions
knrocommented, Jun 14, 2018

@ericdcobb Yes, it turned out to be CSS from redux-form that was causing this issue. I removed the CSS (and redux-form altogeather) and it works fine now. So most likely contributor is some rogue CSS somewhere.

0reactions
ericdcobbcommented, Jun 13, 2018

@knro did you happen to figure this out?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ResponsiveContainer does not respond to resizing from large ...
Screen rotation on mobile devices does not resize chart from bigger to smaller height. My solution is to use height equals 94% on ......
Read more >
Recharts Responsive Container does not resize correctly in ...
It seems rather hacky but a viable fix is to set width to 99% with a height or aspect ratio. <ResponsiveContainer width="99%" aspect={3}>....
Read more >
Recharts Responsive Container does not resize correctly in ...
So far I have found no downsides to this, but YRMV. It seems rather hacky but a viable fix is to set width...
Read more >
Recharts Responsive Container does not resize correctly in ...
I'm trying to create a custom collapsable legend for my data visualization app. It uses react and recharts. the component renders nicely the...
Read more >
ResponsiveContainer | Recharts
The minimum height of the container. debounceNumber. If specified a positive number, debounced function will be used to handle the resize event. DEFAULT ......
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