0

How can I define the format for Drilldown Pie Charts in Highcharts similar to the way we do it using series.dataLabels.format for normal pie charts?

This is code the way I have done it for a normal pie chart. Once I drilldown, I want to it be in some other format than {point.name}({point.count}): {point.y:.1f}%.

series: {                         
    dataLabels: {
        enabled: true,
        format: '{point.name}({point.count}): {point.y:.1f}% ',
        inside: true,
        position: {
            x: 10,
            y: -100
        }
    }
}
David Buck
  • 3,752
  • 35
  • 31
  • 35

1 Answers1

0

You can set wanted format inside the drilldown.series options.

Code:

drilldown: {
        series: [
            {
                    dataLabels: {
                    format: '{point.name} test test test'
                },
                name: "Chrome",
                id: "Chrome",
                data: [
                    [
                        "v65.0",
                        0.1
                    ]...
         }]
     }

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

API: https://api.highcharts.com/highcharts/drilldown.series

Sebastian Wędzel
  • 11,417
  • 1
  • 6
  • 16
  • Thanks Sebastian. It worked. I just want to know where does the {point.name} for drilldown come from? If {point.name} gets me 'v65.0' in data then how can I access '0.1' in data? – Ameya Babhulgaonkar Feb 13 '20 at 10:16
  • It is taken from your data, where first value is a name and second is a 'y' value. You can use the `format: '{point.y}' to display value. Demo: https://jsfiddle.net/BlackLabel/ac5o1f6q/ API: https://api.highcharts.com/highcharts/series.line.dataLabels.format – Sebastian Wędzel Feb 13 '20 at 13:26
  • Thank you Sebastian. Can't I label the fields the way I want? eg. I want {point.tag} instead of {point.name} – Ameya Babhulgaonkar Feb 13 '20 at 16:37
  • Actually you can, but this will require to change the data format to an array of objects where the tag will be defined. Like here: https://jsfiddle.net/BlackLabel/zeh96ps1/ – Sebastian Wędzel Feb 14 '20 at 11:39