1

我正在尝试使用 Google Visualizations 编写条形图。

https://developers.google.com/chart/interactive/docs/gallery/barchart

条形图是动态生成并多次更改的。

Google Visualizations 似乎无法检测我通过 jQuery 动态附加的 div 元素的尺寸。因此,我想将条形图的尺寸硬编码到我输入 Google Visualizations 的选项中。

我怎么做?

我已经尝试过这些选项。

var options = {
    title: 'Comparing Kangeroos and Wallabies',
    vAxis: {title: 'Factors',  titleTextStyle: {color: 'red'}},
    legend: 'bottom',
    chartArea.width: '400px',
    fontName: 'Arial Narrow'
};

然而,Chrome Web Developer 只是注意到“chartArea.width”中有一个意想不到的时期。

4

2 回答 2

2

尝试在您提供的页面chartArea:{width:400}中的表格中的 chartArea 示例中显示。

编辑:更改为数字,因为它说“一个简单的数字是以像素为单位的值”。

于 2012-04-16T21:39:03.817 回答
1

该示例显示:

title:"Yearly Coffee Consumption by Country",
            width:600, height:400,
            vAxis: {title: "Year"},
            hAxis: {title: "Cups"}

所以尝试“宽度”而不是“chartArea.width”

于 2012-04-16T21:31:11.947 回答