2017-07-25 112 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。 –