Highcharts的onReady事件? [英] Highcharts's onReady event?

查看:189
本文介绍了Highcharts的onReady事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



目前,HighCharts只提供 onReady (或类似的) code> addSeries ,点击加载重绘选择为图表对象( http://www.highcharts.com/ref/#chart-events )。显然,加载应该是在图表就绪事件上触发的事件,但事实并非如此。它会触发事件当数据被加载时

下面是他们对 load http://jsfiddle.net/hgbQm/



这里是当 load 被触发时,显示图表的上述代码的修改版本尚未准备就绪: http://jsfiddle.net/QzKky/1/



任何想法?



或者,我需要做一个延迟的呼叫,但这将是如此丑陋。谢谢!

解决方案

的确,延迟呼叫并不是一个很好的方法。 加载事件工作正常,但当前图表由 this 关键字引用,即

  //创建图表
var chart = new Highcharts.Chart({
图表:{
renderTo: 'container',
events:{
load:function(event){
//当图表就绪时,
console.log(this); // this指
}
}
},
xAxis:{
},

系列:[{
动画:假,
数据:[29.9,71.5,106.4,129.2,144.0,176.0,135.6,148.5,216.4,194.1,95.6,54.4]
}]
});

演示



希望这有助于:)


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

Currently, HighCharts only offers addSeries, click, load, redraw, and selection for chart object (http://www.highcharts.com/ref/#chart-events). Apparently the load should be the one which fires "on chart ready" event, but it's not. It's firing the event "when data is loaded"

Here is a sample they have for load: http://jsfiddle.net/hgbQm/

Here is a modified version of the above code which shows the chart is not ready when load is fired: http://jsfiddle.net/QzKky/1/

Any idea?

Alternatively, I will need to do a delayed calls but that will be so ugly. Thanks!

解决方案

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

这篇关于Highcharts的onReady事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆