Chart redraw event handler
Description
The following code shows how to create a chart redraw event handler.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(function () {<!--from w w w. ja v a2 s . c o m-->
$('#container').highcharts({
chart: {
events: {
redraw: function () {
var label = this.renderer.label('The chart was just redrawn', 100, 120)
.attr({
fill: Highcharts.getOptions().colors[0],
padding: 10,
r: 5,
zIndex: 8
})
.css({
color: 'black'
})
.add();
setTimeout(function () {
label.fadeOut();
}, 1000);
}
}
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [129.9, 171.5, 106.4, 19.2, 14.0, 176.0, 35.6, 148.5, 16.4, 194.1, 5.6, 154.4]
}]
});
$('#button').click(function () {
var chart = $('#container').highcharts();
chart.addSeries({
data: [161.4, 14.1, 195.6, 14.4, 129.9, 11.5, 161.4, 19.2, 114.0, 16.0, 15.6, 48.5]
});
$('#button').unbind('click');
});
});
</script>
</head>
<body>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
<button id="button" class="autocompare">Add series</button>
</body>
</html>