Javascript 具有父级宽度的Google饼图

Javascript 具有父级宽度的Google饼图,javascript,html,css,twitter-bootstrap-3,google-visualization,Javascript,Html,Css,Twitter Bootstrap 3,Google Visualization,我使用的是bootstrap3,假设我有如下内容: <div class="col-xl-4 col-lg-4 col-md-4 col-sm-4 col-xs-4"> <div class="well"> <header>Genel İstatistik</header> <content id="general"></content> <footer&g

我使用的是
bootstrap3
,假设我有如下内容:

<div class="col-xl-4 col-lg-4 col-md-4 col-sm-4 col-xs-4">
    <div class="well">
         <header>Genel İstatistik</header>
         <content id="general"></content>
         <footer>Footer</footer>
    </div>
</div>

Genelİstatistik
页脚
我希望我的图表具有div的宽度,并按宽度自动调整高度,在这种情况下,宽度由
col-*-4
规则定义。如何在
选项
中将宽度设置为100%到父级


这是。

好的,所以似乎没有内置的方法来定义谷歌饼图的宽度。然而,我找到了一条出路,就是这样。根据Google上的文档,将示例
options
变量传递到
.draw()
函数将定义大小,
options
如下所示:

var options = {'title':'How Much Pizza I Ate Last Night',
               'width':400,
               'height':300};
所以,我所要做的就是得到
文档的宽度
,然后做一些简单的数学运算,比如:

var width = $(document).width();

var options = {'title':'How Much Pizza I Ate Last Night',
               'width':width/3,
               'height':300};

width/3
对我来说很好,但您可能希望获取父级的宽度,然后应用。在这种情况下,您可能需要查看。

在此处复制代码并发布更新的链接,添加fiddle以使图表响应,在
窗口上侦听
“调整大小”
,设置图表选项,重新绘制图表-->