RasmusGlenvig
RasmusGlenvig

Reputation: 765

Highchart uncaught error - Uncaught TypeError: $(...).highcharts is not a function

I am currently working with Highcharts and it keeps giving me this error in the console: Uncaught TypeError: $(...).highcharts is not a function

I have searched around for a solution and all are saying that you need to place the jquery script above the HighCharts script like this:

<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>

But it still keeps giving me that error. Can it be because of the jquery version?

Here is my code:

HTML:

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

JS:

$(function () {
            $('#container').highcharts({
                chart: {
                    type: 'line'
                },
                title: {
                    text: 'Monthly Average Temperature'
                },
                subtitle: {
                    text: 'Source: WorldClimate.com'
                },
                xAxis: {
                    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
                },
                yAxis: {
                    title: {
                        text: 'Temperature (°C)'
                    }
                },
                plotOptions: {
                    line: {
                        dataLabels: {
                            enabled: true
                        },
                        enableMouseTracking: false
                    }
                },
                series: [{
                    name: 'Tokyo',
                    data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
        }, {
                    name: 'London',
                    data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
        }]
            });
        });

Is there something that I'm not seeing?

Thanks for the help!

Upvotes: 0

Views: 1667

Answers (1)

RasmusGlenvig
RasmusGlenvig

Reputation: 765

I found the solution!

It was pretty simple. I am using a Foundation 6 basic template and apparently before the closing </body> tag there was this script tag <script src="bower_components/jquery/dist/jquery.js"></script> and if I removed that, there are no errors. Just a bad mistake from my side.

Have a nice day!

Upvotes: 1

Related Questions