我目前正在使用ChartWrapper和ControlWrapper在我一直在从事的一个项目中开发一些实用程序。让我使用来自示例中的控件和仪表板的示例:
var pieChart = new google.visualization.ChartWrapper({
'chartType': 'PieChart',
'containerId': 'chart_div',
'options': {
'width': 300,
'height': 300,
'pieSliceText': 'value',
'legend': 'right'
}
});我知道pieChart的类型是ChartWrapper,但我使用的是PieChart对象来绘制图表。现在,如何设置PieChart对象的选项,而不是ChartWrapper的选项?我尝试使用getChart,但总是返回null。我认为ChartWrapper有一个PieChart类型的对象。如果我能以某种方式访问该对象,那么我就可以设置一些选项来满足我的需求。有人知道怎么做吗?
发布于 2012-06-11 04:29:19
来自getChart documentation,这可能解释了为什么你会得到null:
在您对ChartWrapper对象调用
()之前,这将返回null,并抛出一个就绪事件。
如果你想设置这些选项,你可以直接在ChartWrapper对象上设置它们。
pieChart.setOption("width", 400);或者,您可以从头开始设置所有选项:
pieChart.setOptions( {
'width': 300,
'height': 300,
'pieSliceText': 'value',
'legend': 'right'
} );https://stackoverflow.com/questions/10972032
复制相似问题