score:12
The easiest way is to create the events as you described in the first example, and in those functions execute all necesary event handlers from an array.
Something like:
var redrawCallbacks = [];
$(...).highcharts({
chart: {
events: {
redraw: function(event) {
for (var i = 0; i < redrawCallbacks.length; ++i) redrawCallbacks[i].call(this, event);
}
}
}});
See full example at: http://jsfiddle.net/5S6hF/2/
UPDATE
Assuming you are using the default jQuery adapter, you can define events later with:
$(chart).on('redraw', function(){ alert('new event handler'); });
See demo at http://jsfiddle.net/5S6hF/6/
score:0
You need to add callback (like event load), where you can also add redraw events. You need ot do this before creating chart.
See: http://jsfiddle.net/5S6hF/5/
var redrawCallbacks = [];
function appendOnRedrawEvent(callback) {
redrawCallbacks.push(callback);
}
var loadCallbacks = [];
function appendOnLoadEvent(callback) {
loadCallbacks.push(callback);
}
appendOnLoadEvent(function () {
alert('onload added dynamically');
});
H = Highcharts;
H.Chart.prototype.callbacks.push(function (chart) {
for (var i = 0; i < loadCallbacks.length; ++i) loadCallbacks[i].call(this, event);
H.addEvent(chart, 'redraw', function (e) {
for (var i = 0; i < redrawCallbacks.length; ++i) redrawCallbacks[i].call(this, event);
});
});
//create chart
$('#container').highcharts({
series: [{
data: [29.9, 71.5]
}]
});
appendOnRedrawEvent(function () {
alert('redraw added later');
});
score:1
For Highchart 4.2, you have to use the addEvent method to add event to chart object. Follow the below code, first retrieve highchart object and then add redraw/load event to it
var chart1= Highcharts.charts[0];
Highcharts.addEvent(chart1,'redraw', function(){alert('hi');});
Source: stackoverflow.com
Related Query
- Append onload or redraw event functions dynamically in Highcharts
- Dynamically set click event on bar from highcharts graph
- Accessing functions in a highcharts click event in an ionic project
- Highcharts event handler after finishing redraw
- Highcharts + Angularjs : Graph doesn't redraw when adding series from an external event
- Dynamically add an event to Highcharts series
- Highcharts : click event not detected after a redraw
- Highcharts -- Dynamically apply "halo" effect to points without triggering hover event
- How to dynamically change mouse event functions in Highchart?
- Dynamically changing Highcharts Theme through Jquery code not working
- How to call a method on a function OR how to redraw Highcharts dynamically
- Changing data dynamically for a series in Highcharts
- Highcharts - manually trigger hover event on a point
- Changing series color in highcharts dynamically
- How do I add an event listener to a Highcharts object *AFTER* I've created it
- How do I dynamically change a data point in Highcharts using JavaScript
- Highcharts dynamically change bar color based on value
- Highcharts - fire legendItemClick event
- Dynamically update subtitle on Highcharts chart?
- Changing Highcharts data series type dynamically
- Highcharts pie chart dynamically changes size
- Highcharts - Double click event
- Highcharts dynamically add/change yAxis plotLines
- Highcharts chart click event fired on click of the reset zoom button (bug?)
- Dynamically update Highcharts chart in react
- Highcharts : Chart with drilldown how to obtain click event of drill up button
- HighCharts Dynamically Change Chart Type
- highcharts how to catch and insert logic in click reset zoom button event
- Changing the color of the point dynamically in highcharts
- Dynamically applying plot bands to a Highcharts graph
More Query from same tag
- Highcharts --> organisation chart --> toggle visibility of node
- Highchart gauge not displaying min/max value in Vue.js
- Why doesn't highcharts solidgauge charts scale the way I expect?
- Highcharts - add custom information to tooltip what caused price raise or price drop
- How to detect the correct date format in highcharts
- How to a show a block between two points in highchart
- Complicated Rails query for reports with missing data
- Highcharts Tooltip display different data
- Posted value is not getting in the where clause with json highcharts-php and mysql
- Positioning Highstock Zoom Buttons outside the chart area within a <div>
- Highcharts - Multiple Subtitle (2)
- highcharts using pie chart plotOptions
- Add values to rCharts hPlot tooltip
- HighCharts legend.value and legend.percent items to 2 decimal points Math.Round()
- Change legend size in highmaps?
- how to add custom class name to tick positioner in Highcharts using javascript
- How to show current value on two x-axis using Highcharts?
- More Than 2 Y axis in Grafana
- Highcharts add an image to that chart with an onClick event attached to it
- Highcharts donut separate tooltips for inner and outer pie
- How to dynamically add grouped _categories in Highcharts in MVC
- how to pass values to tooltip which not in x and y axis in highcharts
- Trying to produce a pop up when the chart is clicked. The pop up is a close button
- how I can get a static tooltip on a plotline, highstock?
- 3d High Charts Multiple Series inside of Drilldown
- Highcharts: how to use multiple line formats in one series?
- How to convert this require statement to import using systemjs / es6?
- how to remove time from Highstock chart at navaigater bar?
- Enable Highcharts Exporting On Click
- Highcharts/highstock animate series when change the time period button