How do you set the size of a google chart in percentage : I have this in the html:
<div id="chart_div" width="90%" height="20%"></div>
and no width nor height in the options in the js.
But the chart size doesn't adapt to the viewport.
Thanks
How do you set the size of a google chart in percentage : I have this in the html:
<div id="chart_div" width="90%" height="20%"></div>
and no width nor height in the options in the js.
But the chart size doesn't adapt to the viewport.
Thanks
By multiplying with appropriate factor to $(window).width() or $(window).height() in the chart options
First, use styles to set your dimensions, not attributes:
The chart will draw to the size of the div by default, but the charts are not responsive. You have to hook a "resize" event handler to the window (or other element if you are resizing within a window) that redraws the chart:
Please Remove the width and the height properties from the options in the scripts and then add the following style to your page
Google recommend that you style, like the answer above, with correct CSS and this makes a less-glitchy Chart. However, you can size it up in Javascript...
https://developers.google.com/chart/interactive/docs/basic_customizing_chart
So, for the options when you draw the chart (using
chart.draw(data, options)
as above)...A good fiddle for a responsive design is here...
http://jsfiddle.net/toddlevy/pyAz5/