我正在尝试使用AJAX调用制作一个谷歌图表,响应是这个字符串写成在php中创建的数组
['A', "Test 1","Test 2","Test 3","Test 4"],['01-06-2015', 2 , 0 , 0 , 0 ],['03-06-2015', 0 , 5 , 4 , 0 ],['05-06-2015', 2 , 0 , 0 , 0 ],['06-06-2015', 8 , 0 , 0 , 0 ],['02-06-2015', 0 , 5 , 0 , 3 ],['04-06-2015', 0 , 7 , 0 , 0 ]
然后尝试用AJAX制作图表
success: function(response)
{
console.log(response);
var data = google.visualization.arrayToDataTable([response]);
var view = new google.visualization.DataView(data);
var options = {
title: "Projects by employees",
vAxis: {title: "Projects", ticks: [1,2,3,4,5,6,7,8,9]},
hAxis: {title: "Days"},
seriesType: "bars"
};
var chart = new google.visualization.ComboChart(document.getElementById("chart_div"));
chart.draw(view, options);
}
我在控制台中收到错误消息“未捕获错误:第一行不是数组”。 可能是因为他只是将单词响应放在函数中。