我的任务是将动态数据插入到Google PieChart
.
在该链接中,我插入以下代码:
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.DataTable();
var mycars=["Saab","Volvo","BMW"];
var mypoints=[4,12,45];
data.addColumn('string', 'Cars');
data.addColumn('number', 'Numbers');
data.addRows(mycars.length);
for (var i = 0; i < mycars.length; i++){
data.setCell(i,0,mycars[i]);
data.setCell(i,1,mypoints[i]);
}
// Create and draw the visualization.
new google.visualization.PieChart(document.getElementById('visualization')).
draw(data, {title:"So, how was your day?"});
}
</p>
在下面的示例中,我得到了动态数组mycars
,mypoints
然后我尝试将这些数组插入到图表中for loop
。
饼图未显示。那有什么问题?