admin管理员组文章数量:1395902
I just added a chart from Google Charts API into a webapp I'm working on. Just for some context, my webapp is built on AngularJS with Bootstrap. The charts are inserted using the angular-google-chart module.
How do I make the chart display responsive? What I'd like to do is to keep the chart full width, and based on that sized automatically with a proper height. I can't seem to get that working.
I have tried making width: 100%; height: 500px;
but it displays whitespace on smaller widths.
Any suggestions greatly appreciated.
I just added a chart from Google Charts API into a webapp I'm working on. Just for some context, my webapp is built on AngularJS with Bootstrap. The charts are inserted using the angular-google-chart module.
How do I make the chart display responsive? What I'd like to do is to keep the chart full width, and based on that sized automatically with a proper height. I can't seem to get that working.
I have tried making width: 100%; height: 500px;
but it displays whitespace on smaller widths.
Any suggestions greatly appreciated.
Share Improve this question asked May 24, 2014 at 15:38 mushroommushroom 1,9453 gold badges16 silver badges33 bronze badges 3- possible duplicate of Make Google Chart Gauge responsive – asgallant Commented May 24, 2014 at 16:08
- @asgallant: Definitely not a duplicate. Please read the question and context before marking it as such. This is with regard to angular-google-chart, an AngularJS module. – mushroom Commented May 24, 2014 at 18:01
- The answer is the same, regardless of whether it is an angular module or not: you have to redraw the chart from a resize event handler. – asgallant Commented May 25, 2014 at 1:06
1 Answer
Reset to default 5This thing works for me fine:
Add a wrapper (div) on the main chart div and add following css
min-height:500px;height: 100%;width: 100%;margin:auto;background:#fff;text-align:center
Add the following CSS to the chart div:
min-height:500px;height: 100%;width: 100%;margin:auto;background:#fff;text-align:center
Add a simple window resize function
$(window).resize(function(){ drawChart(); });
本文标签: javascriptGoogle Charts API Responsive DesignStack Overflow
版权声明:本文标题:javascript - Google Charts API: Responsive Design - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744092924a2589757.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论