我正在使用谷歌图表api。我使用json数据与谷歌图表中的数据表绑定。我通过ajax调用调用json数据。Json数据正确然后我解析这些数据并将其保存到数组中。当我将数组值提供给DataTabel x 轴然后谷歌图表不显示。请帮助我。
<script type="text/javascript">
google.load('visualization', '1', { packages: ['corechart'] });
google.setOnLoadCallback(drawChart);
function drawChart() {
var Name = [];
var jsonData = $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "NewDashboard.aspx/DisplayData",
data: "{}",
dataType: "json",
success: function (result) {
var contact = JSON.parse(result.d);
for (var i = 0; i < contact.length; i++) {
Name.push([contact[i].VehicleName]);
}
var wrapper = new google.visualization.ChartWrapper({
chartType: 'ColumnChart',
dataTable: [['',Name[0], Name[1],Name[3]s],
['', 700, 300, 400]],
options: { 'title': 'Countries' },
containerId: 'visualization'
});
wrapper.draw();
},
error: function (result) {
alert("Error");
}
});
}
</script>