1
我試圖用this example in their documentation從PHP代碼填充Google Chart。Google Charts - 「this.ug不是函數」
通過精確地遵循格式,我不斷收到JS錯誤:this.ug is not a function
。
的仔細格式化無休止地檢查JSON小時之後才發現的格式完美的每一次,我結束了創建一個的jsfiddle是用自己的例子在這裏複製的問題:
什麼我在這裏完成的不是使用AJAX,而是簡單地將sampleData.json
文件的內容複製爲DataTable()
參數。
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.DataTable({
"cols": [
{"id":"","label":"Topping","pattern":"","type":"string"},
{"id":"","label":"Slices","pattern":"","type":"number"}
],
"rows": [
{"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]},
{"c":[{"v":"Onions","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Olives","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]}
]
});
var options = {
'width' : 400,
'height' : 900
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
在此先感謝您的任何指導。
我可以吻你。非常感謝!這就是我編碼12小時的結果。 :/ – Leng