Highcharts Treemap, drillup event

Tags: ,



I have a nice javascript treemap and am able to add events for drilldown events like so:

series: [{
    point: {
      events: {
        click: function(event){
          alert(this.name);
          alert(event.point);
      }
    }

I’m not able to add a similar event when drilling back up, when clicking the back button.

I tried:

Highcharts.chart('container1', {
  chart : {
    events : {
      drillup : function(event){
          alert("DA");
      }
    }
  },
  series: [{
    point: {
      events: {
        click: function(event){
          alert(this.name);
          alert(event.point);
        },
        drillup : function(event){
          alert("DA");
        }

      }
    }

but neither the drillup in series nor chart seems to work, how can i achieve this?

https://jsfiddle.net/ofg9k3m8/6/

Answer

I found a workaround here: https://github.com/highcharts/highcharts/issues/9812

Highcharts.addEvent(Highcharts.Series, 'click', function() {
  alert('drill down');
});

(function(H) {
  H.wrap(H.seriesTypes.treemap.prototype, 'drillUp', function(proceed) {
    // add code here to run before the drillup
    alert('before drill up');

    // proceed
    proceed.apply(this, [].slice.call(arguments, 1));

    // add code here to run after the drillup
    alert('after drill up');
  });
}(Highcharts))

Here’s the updated https://jsfiddle.net/k9c80za7/1/



Source: stackoverflow