【问题标题】:jquery Donut Pie graph not displaying pagejQuery甜甜圈饼图不显示页面
【发布时间】:2015-04-25 20:09:27
【问题描述】:

我正在尝试在 html 中显示 jQuery 甜甜圈饼图

刚刚在我的页面中实现了这个

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

        <script>
            $(function () {
                // Create the chart
                chart = new Highcharts.Chart({
                    chart: {
                        renderTo: 'container',
                        type: 'pie'
                    },
                    title: {
                        text: 'Browser market share, April, 2011'
                    },
                    yAxis: {
                        title: {
                            text: 'Total percent market share'
                        }
                    },
                    plotOptions: {
                        pie: {
                            shadow: false
                        }
                    },
                    tooltip: {
                        formatter: function () {
                            return '<b>' + this.point.name + '</b>: ' + this.y + ' %';
                        }
                    },
                    series: [{
                            name: 'Browsers',
                            data: [["Firefox", 6], ["MSIE", 4], ["Chrome", 7], ["opera", 7]],
                            size: '60%',
                            innerSize: '20%',
                            showInLegend: true,
                            dataLabels: {
                                enabled: false
                            }
                        }]
                });
            });
        </script>
        <script src="http://code.highcharts.com/highcharts.js"></script>
        <script src="http://code.highcharts.com/modules/exporting.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    </body>
</html>

当我运行我的页面时,页面中没有显示任何内容,它只是一个空白页面

当我检查浏览器控制台时,我看到以下错误

Uncaught ReferenceError: $ is not defined(anonymous function) @ Donut_pie+two.php:18
highcharts.js:306 Uncaught TypeError: Cannot read property 'addEvent' of undefined(anonymous function) @ highcharts.js:306(anonymous function) @ highcharts.js:308(anonymous function) @ highcharts.js:324
exporting.js:9 Uncaught TypeError: Cannot read property 'fireEvent' of undefined(anonymous function) @ exporting.js:9(anonymous function) @ exporting.js:23

谁能帮我看看这有什么问题

【问题讨论】:

    标签: javascript jquery graph


    【解决方案1】:

    放置你的

     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    

    &lt;script&gt;&lt;/script&gt; 标签之前

    这样

    <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script>
        $(function () {
            // Create the chart
            chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'container',
                    type: 'pie'
                },
                title: {
                    text: 'Browser market share, April, 2011'
                },
                yAxis: {
                    title: {
                        text: 'Total percent market share'
                    }
                },
                plotOptions: {
                    pie: {
                        shadow: false
                    }
                },
                tooltip: {
                    formatter: function () {
                        return '<b>' + this.point.name + '</b>: ' + this.y + ' %';
                    }
                },
                series: [{
                        name: 'Browsers',
                        data: [["Firefox", 6], ["MSIE", 4], ["Chrome", 7], ["opera", 7]],
                        size: '60%',
                        innerSize: '20%',
                        showInLegend: true,
                        dataLabels: {
                            enabled: false
                        }
                    }]
            });
        });
    </script>
    <script src="http://code.highcharts.com/highcharts.js"></script>
    <script src="http://code.highcharts.com/modules/exporting.js"></script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多