Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts Error #16: charts not showing on the same page

i have a website, one page i have successfully added an highchart.

now i copied exactly the same code to the same page, but diffrent asp page, but the first chart has disappeared and the 2nd chart is not showing.

it is giving me an error:

Uncaught Highcharts error #16: www.highcharts.com/errors/16 highcharts.js:16
Uncaught SyntaxError: Unexpected token ILLEGAL Dashboard.aspx:657
Uncaught TypeError: Object [object Object] has no method 'highcharts' Dashboard.aspx:405
Uncaught TypeError: Object [object Object] has no method 'draggable' 

any ideas why am getting this.

so my code for the new chart i want:

 <script type="text/javascript"
$(function () { 
 $('#container').highcharts({
    chart: {
        type: 'bar'
    },
    title: {
        text: 'Fruit Consumption'
    },
    xAxis: {
        categories: ['Apples', 'Bananas', 'Oranges']
    },
    yAxis: {
        title: {
            text: 'Fruit eaten'
        }
    },
    series: [{
        name: 'Jane',
        data: [1, 0, 4]
    }, {
        name: 'John',
        data: [5, 7, 3]
    }]
});
});​
></script>

the chart that is working has the following code:

 <script type="text/javascript"     src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>



  <script type="text/javascript">

   $(function() {

       $('#container').highcharts({
           chart: {
               type: 'column'
           },
           title: {
               text: 'Chart'
           },
           xAxis: {
           categories: array1
           },
           yAxis: {
               title: {
                   text: 'aWH'
               }
           },
           tooltip: {
               pointFormat: "Value: {point.y:.1f} mm"
           },

           series: [{

               name: '2011-2012',
               color: '#0000FF',
               data: array
           },
           {

               name: '2012-2013',
               color: '#92D050',
               data: array3
           },


             {

                 color: '#FF0000',
                 name: '2013-2014',
                 data: array2
}]
       });

   });

</script>

the 2nd chart shows.

but the first chart doesnt,

both code is in diffrent acsx page!

like image 328
m ali Avatar asked Jun 28 '13 11:06

m ali


People also ask

How do I fix Highcharts Error 13?

Re: How to turn off Error #13This error occurs if the chart. renderTo option is misconfigured so that Highcharts is unable to find the HTML element to render the chart in. Can you post your data (json returned from your site) to enable replication? Please prepare your live example with the error.

Can I use Highcharts for free?

Highcharts is a software library for charting written in pure JavaScript, first released in 2009. The license is proprietary. It is free for personal/non-commercial uses and paid for commercial applications.

What is the latest version of Highcharts?

Highcharts v9. 1.1 (2021-06-04)


1 Answers

You can use this way to wrap the code which runs Highcharts.js library.:

if (!window.HighchartsUniqueName) {
  window.HighchartsUniqueName = true;

  // .. your code which runs Highcharts.js library here ... 

}

I found it here https://stackoverflow.com/a/5154971 and it works for me.

In this way you don't need to put your script in the MasterPage if you don't want.

Be sure to use a very unique name, since it's a global variable.

Also keep in mind that the Highcharts.Chart constructor and all features of Highcharts are included in Highstock, so if you are running Chart and StockChart in combination, you only need to load the highstock.js file or you can wrap it in the same way.

like image 159
Nikolay Bolonin Avatar answered Sep 17 '22 09:09

Nikolay Bolonin