Caesar Tex
Caesar Tex

Reputation: 295

Adding custom data to High Charts data export

I have a pie chart with tooltip showing some extra data. How do I get this data to be exported with datatable?

I need {point.custom} to be added as a column when you click on export > view DataTable

JSFiddle Link : https://jsfiddle.net/mewohraz/1/

Highcharts.chart('container', {
chart: {
    plotBackgroundColor: null,
    plotBorderWidth: null,
    plotShadow: false,
    type: 'pie'
},
title: {
    text: 'Browser market shares in January, 2018'
},
tooltip: {
    pointFormat: '{point.custom}'
},
plotOptions: {
    pie: {
        allowPointSelect: true,
        cursor: 'pointer',
        dataLabels: {
            enabled: true,
            format: '<b>{point.name}</b>: {point.percentage:.1f} %',
            style: {
                color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
             }
         }
     }
 },
 series: [{
     name: 'Brands',
     colorByPoint: true,
     data: [{
        name: 'Chrome',
        y: 61.41,
        custom: 200,
        sliced: true,
        selected: true
     }, {
        name: 'Internet Explorer',
        y: 11.84,
        custom: 100
     }, {
        name: 'Firefox',
        y: 10.85,
        custom: 300
     }]
 }]
});

Upvotes: 0

Views: 393

Answers (1)

ppotaczek
ppotaczek

Reputation: 39099

You can add custom data by keys property:

keys: ['x', 'y', 'custom']

Live demo: https://jsfiddle.net/BlackLabel/3m82ck5w/

API Reference: https://api.highcharts.com/highcharts/series.pie.keys

Upvotes: 1

Related Questions