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

但我只收到一条错误消息:

表没有列。

有人可以帮我吗?

谢谢

4

1 回答 1

0

不幸的是,我无法发表评论。

此代码有效 -小提琴。你能提供更多关于这个项目的细节吗?

小提琴的代码示例

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

编辑:

表没有列。

这是来自浏览器控制台的错误消息吗?

于 2017-07-25T13:43:14.203 回答