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.

Responsive charts issue when using FlexBox or CSS grids

See original GitHub issue

Reproducible demo here: https://codesandbox.io/s/lp16vvz6n7

As you can see, the top chart here (in the flex row) is not responsive.

Happy to help contribute if no one on the core team immediately knows. It might have something to do with react-measure that’s used in @nivo/core for the <ResponsiveWrapper> component.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:17
  • Comments:19

github_iconTop GitHub Comments

32reactions
ja0nzcommented, Mar 26, 2019

I solved this issue with the AutoSizer HOC.

import { AutoSizer } from 'react-virtualized'
<AutoSizer>
    {({ height, width }) => (
        <Pie
            height={height}
            width={width}
            ...
         />
    )}
</AutoSizer>

Because of the known issues like “infinitely growing diagrams” I almost always use the AutoSizer wrapper in favour of the <Responsive*> components.

23reactions
TerryCLAWongcommented, Jan 18, 2021

I think I had a similar issue where my <ResponsiveBar> would respond if zooming out but would not shrink when zooming in with my React app. The fix was to put the <ResponsiveBar> into a <div> that had a width of less than 100%.

So the following fixed my problem:

<div style = {{width: "99%"}}>
<ResponsiveBar
...
/>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Relationship of grid layout to other layout methods - CSS
In this guide, I will explain how a grid fits together with other ... The basic difference between CSS Grid Layout and CSS...
Read more >
Solving Layout Problems With CSS Grid and Friends - YouTube
CSS Grid Layout launched into the majority of our browsers in 2017. As designers and developers have started to use Grid Rachel has...
Read more >
A Complete Guide to CSS Grid
CSS Grid properties ; justify-items · start – aligns items to be flush with the start edge of their cell; end ; align-items...
Read more >
Difference between CSS Grid and CSS Flexbox
CSS Grids helps you create the outer layout of the webpage. You can build complex as well responsive design with this. This is...
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