Javascript Highcharts:未捕获类型错误:$(…)。Highcharts不是函数

Javascript Highcharts:未捕获类型错误:$(…)。Highcharts不是函数,javascript,jquery,jsp,highcharts,Javascript,Jquery,Jsp,Highcharts,在JSP应用程序中运行HighCharts时出现此错误 Uncaught TypeError: $(...).highcharts is not a function(anonymous function) @ VendorReports:125n.Callbacks.j @ jquery-1.11.0.js:893n.Callbacks.k.fireWith @ jquery-1.11.0.js:928n.extend.ready @ jquery-1.11.0.js:982K @ jquer

在JSP应用程序中运行HighCharts时出现此错误

Uncaught TypeError: $(...).highcharts is not a function(anonymous function) @ VendorReports:125n.Callbacks.j @ jquery-1.11.0.js:893n.Callbacks.k.fireWith @ jquery-1.11.0.js:928n.extend.ready @ jquery-1.11.0.js:982K @ jquery-1.11.0.js:989
请建议怎么做

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

如果你换一个新的会发生什么

$('#container').highcharts({
        colors: ["#7cb5ec", "#f7a35c"],
        chart: {
            type: 'column'
        },
        /* ... */

?


不久前我遇到了与您相同的问题,我通过使用这种类型的初始化解决了这个问题

从官方示例中采用的方法效果良好。他们在body标记中定义了include脚本标记,因此我认为Kabulan0lak给出的解决方案更好

<html>
<head>
    <title>Highcharts Example</title>

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#container').highcharts({
                chart: {
                    type: 'spline'
                }
                // ... other options and data/series
            });
        });
    </script>
</head>

<body>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
</body>
</html>

海图示例
$(函数(){
$(“#容器”)。高图({
图表:{
类型:“样条线”
}
//…其他选项和数据/系列
});
});

我也遇到了这个问题。确保在highchart.js之前导入jQuery。这为我解决了这个问题

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>


我使用的是high charts版本的旧版本。从他们的网站上,我假设在特定版本下列出的版本是他们的最新版本,并使用该版本,这样它就不会自动更新到我身上。然而,他们列出的版本非常旧,因此将其更改为实际的最新版本解决了问题。

我也有这种情况。在我的例子中,我需要点击一个按钮来加载图表,如果我点击两次或更多,图表就会停止工作。我是这样设置颜色的:

Highcharts.setOptions({
        colors: Highcharts.map(Highcharts.getOptions().colors, function (color) {
            return {
                radialGradient: {
                    cx: 0.5,
                    cy: 0.3,
                    r: 0.7
                },
                stops: [
                    [0, color],
                    [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
                ]
            };
        })
    });

$.getJSON("./myDataGraph.php", function(response){
        // Create the chart
        var chart = Highcharts.chart('myGraph', {
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                type: 'pie'
            },
... });

我无法解决这个错误,但我删除了“Highcharts.setOptions”并且图表可以工作

你能添加JSFIDLE吗?无法复制,它工作顺利->@Farhan。它在那里工作,但是当把同样的东西放在我的JSP中时,得到了这个错误然后你的JSP出现了一些问题,而不是上面的代码yes@adeneo,我在那里练习并复制到我的页面。这里不工作,但如何调用图表以附加到容器?请查看行
renderTo:'container'
。在这里,您可以定义将图表附加到哪个html元素:它看起来工作,但不显示图形:(…没有错误那么你的系列可能有问题。你如何初始化你的数据?例如,粘贴一个数组样本。但是我想把它呈现给现有的元素。有可能吗?如果我呈现给新元素,它会在页面的末尾绘制。同样,我刚刚意识到highcharts是一个依赖于jQuery的库,因此jQuery必须n高居榜首。只要做出这个改变,任何人都应该做好准备。!太天真了,错了-我怎么能这样做呢!:)
Highcharts.setOptions({
        colors: Highcharts.map(Highcharts.getOptions().colors, function (color) {
            return {
                radialGradient: {
                    cx: 0.5,
                    cy: 0.3,
                    r: 0.7
                },
                stops: [
                    [0, color],
                    [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
                ]
            };
        })
    });

$.getJSON("./myDataGraph.php", function(response){
        // Create the chart
        var chart = Highcharts.chart('myGraph', {
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                type: 'pie'
            },
... });