redraw() doesn't respect changes in containing div's size.
See original GitHub issueI set a listener for window resize events. When fired I call redraw() in my google-chart, as I want my chart to be responsive. to make my chart match the width of it’s containing div when redrawn I have the following css:
google-chart {
width: 100%;
}
This works when starting from a small width and getting bigger. The window resizes and the graph is redraw with the appropriate width. However when going from big to small, it will not redraw smaller to what the new 100% if containing div is, so I end up with an overflow of the containing div.
This is very strange behavior and I can only assume it’s a bug as the redraw is getting called and it will redraw it larger than current but not smaller.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Not respecting parent size · Issue #2422 · chartjs/Chart.js
I solved it by setting maintainAspectRatio to false in the options section, in addition to changing the size of the parent div ....
Read more >Set width of a "Position: fixed" div relative to parent div
Any idea how to solve this if #container width is 50% inside a div with width = 100px (then container width would be...
Read more >CSS- Div- Be Careful When You Size Your Divs
Fortunately, it's easy to fix - although this is an Explorer-only solution! Place both DIVs into a container DIV that's set to 100%...
Read more >Animating CSS Width And Height Without The Squish Effect
In the transform example the radius is not redrawn (like in the width example), it is simply scaled. Redrawing would require a repaint,...
Read more >Plot sizing problems - plotly.js
With autosize not set, the width of the containing div is correctly consumed, but how the height is derived isn't clear. Setting autosize:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

For my workaround in Polymer, I’m using iron-resize behavior to detect the size of the chart container.
Great that you have solved it. I will close this issue then.