我正在使用数据分析并尝试使用谷歌图表。
我尝试通过谷歌分析的响应来生成谷歌图表。
我成功实现了 data.addColumn,但 data.addRow 给出错误“给 addRows 的参数必须是数字或数组”
function drawCharts(response)
{
var data = new google.visualization.DataTable();
header = response.columnHeaders[0];
data.addColumn('string', header.name);
for (var i = 0, header; header = response.columnHeaders[i]; i++){
data.addColumn('number', header.name);
}
var result = '';
for(var i=0; i<response.rows.length; i++) {
result += '["'+response.rows[i]+'"],';
}
result = result.substring(0, result.length - 1);
alert(result); //image attached
data.addRows(result);
var options = {'title':response.profileInfo.profileName,
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
请帮忙....!我已经尝试了几个小时......!
警报结果给了我这样的东西;