Highcharts's onReady event?

后端 未结 3 1202
一个人的身影
一个人的身影 2021-02-19 03:34

Is there any onReady (or similar) ready event for HighCharts?

Currently, HighCharts only offers addSeries, click, load

3条回答
  •  情书的邮戳
    2021-02-19 04:23

    Indeed the delayed call is not a very good approach. The load event is working properly, but the current chart is referred by the this keyword, i.e.

    // create the chart
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            events: {
                load: function(event) {
                    //When is chart ready?
                    console.log(this); //this refers to the loaded chart.
                }
            }        
        },
        xAxis: {
        },
    
        series: [{
            animation: false,
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]     
        }]
    });
    

    Demo

    Hope this helps :)

提交回复
热议问题