2017-07-25 109 views
0

我嘗試在我的網站上創建一個餅圖,我發現示例代碼谷歌餅圖

<div id="piechart"></div> 

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 

<script type="text/javascript"> 
    // Load google charts 
    google.charts.load('current', {'packages':['corechart']}); 
    google.charts.setOnLoadCallback(drawChart); 

    // Draw the chart and set the chart values 
    function drawChart() { 
     var data = google.visualization.arrayToDataTable([ 
      ['Task', 'Hours per Day'], 
      ['Work', 8], 
      ['Eat', 2], 
      ['TV', 4], 
      ['Gym', 2], 
      ['Sleep', 8] 
     ]); 

     // 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.PieChart(document.getElementById('piechart')); 
     chart.draw(data, options); 
    } 
</script> 

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_google_pie_chart

但我只得到一個錯誤信息:

表沒有列。

有人可以幫我嗎?

感謝

回答

0

可惜的是我不能發表評論。

此代碼適用於 - fiddle。你能否提供關於這個項目的更多細節?的代碼爲小提琴

<div id="piechart"></div> 

樣品編輯:

表沒有列。

這是來自瀏覽器控制檯的錯誤消息嗎?

+0

我在商店系統的.tpl文件中使用smarty。 –