[英]Cannot read property 'DataTable' of undefined google charts
I'am developing for a report system based on google maps and i want to show google map data such as car time and speed on a google chart and here is my code: 我正在为基于Google地图的报告系统开发,我想在Google图表上显示诸如行车时间和速度之类的Google地图数据,这是我的代码:
function updatereport() {
//alert("aaa");
$.ajax({
url: 'getreport.php',
data: {
yy: '18',
mm: '05',
dd: '17',
hh: '18',
driverid: '7'
},
type: 'get',
error: function() {
alert("some error ! :(");
},
success: function(result) {
//alert(result);
var myobj = JSON.parse(result);
google.charts.load('visualization', {
'1.0': ['corechart']
});
google.charts.setOnLoadCallback(drawChart(myobj));
} //func
}) //ajax
}
// Draw the chart and set the chart values
function drawChart(myobj) {
var data = new google.visualization.DataTable();
alert("a");
data.addColumn("number", "time");
data.addColumn("number", "speed");
data.addRow();
for (i in myobj)
data.addRows(myobj[i].time);
//var xx=[['T', 'H'],[2, 8.2],[3, .2],[4, 4],[6, 2],[9, 8]];
//var data = google.visualization.arrayToDataTable(xx);
//alert(myobj[1].time);
// Optional; add a title and set the width and height of the chart
var options = {
'title': 'My Average Day',
'width': 550,
'height': 400
};
// Display the chart inside the <div> element with id="piechart"
var chart = new google.visualization.LineChart(document.getElementById('chart'));
chart.draw(data, options);
}
but the problem is when i run this code it shows 但是问题是当我运行此代码时它显示
Cannot read property 'DataTable' of undefined 无法读取未定义的属性“ DataTable”
the load statement doesn't look correct, load语句看起来不正确,
replace this... 取代这个...
google.charts.load('visualization', {
'1.0': ['corechart']
});
with this... 有了这个...
google.charts.load('current', {
packages: ['corechart']
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.