Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
46
rated 0 times [  48] [ 2]  / answers: 1 / hits: 20362  / 13 Years ago, mon, august 8, 2011, 12:00:00

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!


More From » highcharts

 Answers
35

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


[#90749] Saturday, August 6, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sherryd

Total Points: 254
Total Questions: 92
Total Answers: 89

Location: Equatorial Guinea
Member since Sun, Feb 14, 2021
3 Years ago
;