How can I fix Highcharts error #13?

前端 未结 9 2098
迷失自我
迷失自我 2020-12-11 15:59

I use highchart so, the user can close and open the chart page and redraw the chart, in some case give me this error, how can I fix it, Thanks Here is my code



        
相关标签:
9条回答
  • 2020-12-11 16:12

    I faced the same error and what I got to know is that Error#13 occurs when HighCharts.js tries to access an element which is not present in the DOM.

    How I fixed it? I made sure that the HightCharts method is called only after my targeted element is created in the DOM. Bingo!!!! Everything worked fine.

    0 讨论(0)
  • 2020-12-11 16:14

    I had the same issue and fixed it using the correct container:

    In my case I used the following:

    // Use Meteor.defer() to create chart after DOM is ready:
    Meteor.defer(function() {
      // Create standard Highcharts chart with options:
      Highcharts.chart('Charts', {
        chart: {
          renderTo: 'container',
            type: 'column',
            options3d: {
                enabled: true,
                alpha: 15,
                beta: 15,
                depth: 50,
                viewDistance: 25
            }
        },....
      }.....
    }
    
    Template.body.helpers({
      createChart: function () {...}
    

    and in the HTML file:

    <div id='Charts'>
        {{createChart}}
    </div>
    

    I found the fix from Highcharts: http://forum.highcharts.com/viewtopic.php?f=9&t=15610

    Regards.

    0 讨论(0)
  • 2020-12-11 16:22

    For me error was resolved when I placed the calling script after the HTML element.

    Like;

    <div id="container"></div>
    
    <script>    
    Highcharts.chart('container', {
    // some script here
    });
    </script>
    

    Also if you check on high chart site it says:

        This error occurs if the chart.renderTo option is misconfigured so that
    Highcharts is unable to find the HTML element to render the chart in.
    

    https://www.highcharts.com/errors/13

    0 讨论(0)
  • 2020-12-11 16:27

    I loaded script codes after document ready function, and it worked fine.

    $(document).ready(function(){
    });
    
    0 讨论(0)
  • 2020-12-11 16:29

    Categories needs to be a collection, it was like this:

    categories: xaxis
    

    Change it to this:

    categories: ['xaxis']
    

    Some of the data fields need to be enclosed in single quotes like this:

    data: 'blue'
    

    Here is a fiddle without any errors for you:

    http://jsfiddle.net/MVcBe/

    Good luck with the rest. :)

    ps I sometimes find it easier to edit a working fiddle from the highcharts site and adapt it to what you need. Like this one:

    http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-basic/

    0 讨论(0)
  • 2020-12-11 16:32

    I also run into the same error code, but in my case the reason was my data was too large to supported

    0 讨论(0)
提交回复
热议问题