I have a click event on the chart, but if you use the zoom and want to reset the zoom, the click event is also fired.
I've the following chart settings:
$('#container').highcharts({
chart: {
type: 'line',
marginRight: 130,
marginBottom: 25,
zoomType: 'x',
events: {
click: function (event) {
alert('chart click!');
}
}
}...
see working example: http://jsfiddle.net/2Y3ah/
Well this looks like a bug or if it's as designed how to block the click event if the reset zoom button is clicked.
A dirty way can be to look at the srcElement
for example test the following (check if firstChild not null ...)
event.srcElement.firstChild.data === "Reset zoom"
You can recognise if button is clicked, by event.target http://jsfiddle.net/2Y3ah/3/
if(!($(event.target)[0].textContent))
alert('chart click!');
http://api.jquery.com/event.target/
This is the ultimate solution. Just set the following config to the Chart:
$('#container').highcharts({
chart: {
resetZoomButton: {
relativeTo: 'chart'
}
}
});
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