Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In high chart how to add event for label click

Tags:

highcharts

In high chart there is an event for clicking on the bar. But bar is small in height it is impossible to click on it. Hence I want the event in high chart for further processing.

E.g. I want the event for month name in following example. enter image description here

Thanks In advance.

like image 546
Yasin Avatar asked Feb 06 '17 07:02

Yasin


1 Answers

If you don't want to use JQuery you can use it as follows

chart.xAxis[0].labelGroup.element.childNodes.forEach(function(label)
{
    label.style.cursor = "pointer";
    label.onclick = function(){
      alert('You clicked on '+this.textContent);
    }
});

complete code at http://jsfiddle.net/t07ok5v3/5/

like image 99
Malay Sarkar Avatar answered Oct 18 '22 14:10

Malay Sarkar