Highcharts的onReady事件? [英] Highcharts's onReady event?
问题描述
目前,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]
}]
});
Hope this helps :)
这篇关于Highcharts的onReady事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!