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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With