简体   繁体   English

如何覆盖Google Visualization的包含尺寸?

[英]How can I override the containing dimensions of a Google Visualization?

I am trying to program a bar chart using Google Visualizations. 我正在尝试使用Google可视化对条形图进行编程。

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

The bar chart is dynamically generated and changed several times. 条形图是动态生成并多次更改的。

Google Visualizations seems to have trouble detecting the dimensions of a div element that I dynamically appended via jQuery. 谷歌可视化似乎无法检测我通过jQuery动态追加的div元素的维度。 Hence, I would like to hard code the dimensions of the bar chart into the options that I feed into Google Visualizations. 因此,我想将条形图的尺寸硬编码到我提供给Google Visualizations的选项中。

How do I do that? 我怎么做?

I have tried these options. 我试过这些选择。

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

However, Chrome Web Developer just notes that there is an unexpected period in "chartArea.width." 但是,Chrome Web Developer只是注意到“chartArea.width”中存在意外时期。

try chartArea:{width:400} like it shows in the example for chartArea in the table from the page you gave. 尝试chartArea:{width:400}就像它在你给出的页面表格中的chartArea示例中所示。

EDIT: changed to number because it says "A simple number is a value in pixels". 编辑:更改为数字,因为它说“一个简单的数字是一个像素值”。

The example shows: 该示例显示:

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

So try "width" instead of "chartArea.width" 所以尝试“宽度”而不是“chartArea.width”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我怎么知道是否加载了Google Visualization - How can I know if Google Visualization is loaded 如何更改Google可视化表及其列的CSS属性? - How can I change the css properties of a google visualization table and it columns? 如何将json字符串转换为google.visualization.DataTable? - How can I convert json string to google.visualization.DataTable? 使用Google Visualization Geochart色阶的3种颜色尺寸 - 3 color dimensions with Google Visualization Geochart Color Scale 如何在加载图表后抓取Google Visualization DataTable数据? - How can I grab Google Visualization DataTable data after chart is loaded? 如何在Google可视化查询中将C列的值设置为字符串? - How can I set the value of column C as a string in my Google Visualization Query? 如何在Google可视化中画一条线来指示今天/当前日期 - How can I draw a line indicating today's/current date in google visualization 如何在Google Analytics(分析)中跟踪Google可视化图表事件? - How do I track Google visualization chart events in Google analytics? 如何基于同级元素尺寸计算元素尺寸? - How can I calculate element dimensions based on sibling element dimensions? 如何将Google Facets可视化工具嵌入到网页中 - How google facets visualization tool can be embed into web page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM