On-screen event with the click of the reset button with scaling (error?)

I have a click event on the chart, but if you use scaling and want to reset the scaling, the click event also fires.

I have 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 seems like an error or if it is designed to block the click event if the reset zoom button is pressed.

+6
source share
3 answers

A dirty way could be to view srcElement

e.g. check the following (check if firstChild is not null ...)

 event.srcElement.firstChild.data === "Reset zoom" 
+4
source

You can find out if the button is pressed by pressing the event.target button http://jsfiddle.net/2Y3ah/3/

  if(!($(event.target)[0].textContent)) alert('chart click!'); 

http://api.jquery.com/event.target/

+2
source

This is the final decision. Just set the following configuration in the diagram:

  $('#container').highcharts({ chart: { resetZoomButton: { relativeTo: 'chart' } } }); 
+1
source

All Articles