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!
The Highcharts.Chart constructor takes a callback argument that is called "when the chart object is finished loading and rendering". The chart object is passed as an argument to the callback.
Indeed the delayed call is not a very good approach. The
load
event is working properly, but the current chart is referred by thethis
keyword, i.e.Demo
Hope this helps :)
This is definitely less elegant than the accepted answer, but still works fine with a few lines of code. The essence is to simply poll all chart container HTML elements.
The code below assumes you have one or more Highcharts attached to elements having class="chart":