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 loading charts

See original GitHub issue

When i try using <ResponsiveContainer width="100%" height={400}> my charts are not appearing. Also when i try giving width in % for BarChart or PieChart or any other im getting any error width is NaN string is passed.

here is my code:

<ResponsiveContainer width="100%" height={200}>
            <BarChart width={300} height={200} data={data} margins = {{ top: 50, right: 0, bottom: 100, left: 0 }} >
                <XAxis dataKey="monthName" />
                <YAxis />
                <CartesianGrid />
                <Legend />
                <Tooltip />
                <Bar dataKey="transactions" fill="#7B1FA2" />
            </BarChart>
            </ResponsiveContainer>

can you please tell me where am i doing wrong or something to do with your side.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
matepaivacommented, Sep 6, 2017

@vikkya this solves your problem: https://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php

Just wrap your ResponsiveContainer with this below (the paddingBottom will define the proportion of your container (a square, a rectangle etc.):

<div style={{
  paddingBottom: '56.25%', /* 16:9 */
  position: 'relative',
  height: 0
}} >
  <div style={{
    position: 'absolute',
    top: '0',
    left: '0',
    width: '100%',
    height: '100%'
  }}>
      <ResponsiveContainer>...</ResponsiveContainer>
  </div>
</div>
2reactions
xile611commented, Sep 16, 2017

@vikkya Just guarantee the width of parent node.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rechart Responsive container does not render - Stack Overflow
Im trying to render a bar chart to fit ...
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 >
pie-chart-in-responsive-container - CodeSandbox
Activating extension 'vscode.typescript-language-features' failed: Could not find bundled tsserver.js.
Read more >
[Solved]-Rechart Responsive container does not render-Reactjs
For anybody rendering the chart inside a react-bootstrap component, don't use the ResponsiveContainer tag. you can simple use the logic inside of it...
Read more >
How to use the recharts.Scatter function in recharts - Snyk
streamlit / streamlit / frontend / src / components / elements / Chart / Chart.tsx View on ... ResponsiveContainer, <- not implemented Area:...
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