fguru
fguru

Reputation: 71

Highcharts drilldown datalabels different from parent

Need some help, how to show parent values with % and child values without %. Thanks in advance.

 plotOptions: {
    series: {
      borderWidth: 0,
      dataLabels: {
        enabled: true,
        formatter: function() {
    if(this.hasOwnProperty("drilldown")) {
        return this.series.name + ", " + this.y+'%';
    } else {
        return this.series.name + ", " + this.y;
    }
}
        //format: '{point.y:.1f}'
      }
    },
    
  },

Upvotes: 0

Views: 74

Answers (1)

Dominik Chudy
Dominik Chudy

Reputation: 1080

We can simply check if the point has property drilldown. So we need to change your code a little bit:

      if (this.point.drilldown) {
        return this.series.name + ", " + this.y + '%';
      } else {
        return this.series.name + ", " + this.y;
      }

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

Upvotes: 1

Related Questions