Search code examples
highchartsangular-highcharts

Click event in drilldown chart - Highcharts


I am working on an app where I need to show drilldown chart. I am using highcharts for this, I want to fire the click event when user clicks on the bars of second chart (drilled one).

I am using code but this is firing the event on the first chart also. Is there a way to fire it on the second chart only? or check if event is raised from which chart?

 plotOptions: {
    series: {
        events:{
              click: function (event) {
               
                console.log(event);
                   alert("testing" + event.point.name)
                
              }
        }
    }
  }

Sample is here - https://highcharts-angular-drilldown-zqmyd9.stackblitz.io/


Solution

  • Try to define your chart as a global variable and add the condition to check if the chart.drilldownUpButton exists into your click callback.

    Demo: https://jsfiddle.net/BlackLabel/uhbored9/

      plotOptions: {
        series: {
          events: {
            click: function(event) {
                if (chart.drillUpButton) {
                    alert("testing" + event.point.name)
               }
            }
          }
        }
      },