當試圖使用Google圖表代碼繪製折線圖時,我收到此錯誤Google圖表錯誤
錯誤:類型不匹配。值0.8與列索引中的類型編號不匹配0
'0.8'是指代碼中的值p1。
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('number', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
[p1,1.89],
[ch_period[17],5],
[3,2],
[5,2],
[5,2],
[6,7]
]);
// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
你確定'p1'是一個數字嗎?嘗試parseInt(p1) – Kai