Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: $(...).highcharts is not a function [closed]

I had included the jQuery_1.8.2 js file and then included this code but iam getting the error..

TypeError: $(...).highcharts is not a function [Break On This Error]

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]

i just created a div with id container ..where i went wrong..any order of placing js files wrong..?How to resolve this issue..?

 <script>
        buildHighCharts();
        function buildHighCharts(){
                $('#container').highcharts({
                    chart: {
                        type: 'line',
                        marginRight: 130,
                        marginBottom: 25
                    },
                    title: {
                        text: 'Monthly Average Temperature',
                        x: -20 //center
                    },
                    subtitle: {
                        text: 'Source: WorldClimate.com',
                        x: -20
                    },
                    xAxis: {
                        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                            'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
                    },
                    yAxis: {
                        title: {
                            text: 'Temperature (°C)'
                        },
                        plotLines: [{
                            value: 0,
                            width: 1,
                            color: '#808080'
                        }]
                    },
                    tooltip: {
                        valueSuffix: '°C'
                    },
                    legend: {
                        layout: 'vertical',
                        align: 'right',
                        verticalAlign: 'top',
                        x: -10,
                        y: 100,
                        borderWidth: 0
                    },
                    series: [{
                        name: 'Tokyo',
                        data: [7.0, 6.9, 9.5, 14.5, 18.2, 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]
                    }]
                });
            }
            </script>

            <script type="text/javascript" src="js/highcharts1/highcharts-2.3.5.js"></script>
            <script type="text/javascript" src="js/highcharts1/modules/exporting-2.3.5.js"></script>
like image 663
sakar Avatar asked Apr 01 '13 14:04

sakar


2 Answers

any order of placing js files wrong..?

Yes. Your highcharts setup code needs to come after the script tags that loads the highcharts library.

<script type="text/javascript" src="js/highcharts1/highcharts-2.3.5.js"></script>
<script type="text/javascript" src="js/highcharts1/modules/exporting-2.3.5.js"></script>
<script>
    function buildHighCharts(){ ... }
</script>
like image 104
Matt Ball Avatar answered Nov 03 '22 18:11

Matt Ball


You are using highcharts before you added it to the page. The includes need to come before!

like image 3
epascarello Avatar answered Nov 03 '22 16:11

epascarello