将自定义数据添加到高级图表数据导出

时间:2019-02-22 17:47:28

标签: javascript highcharts

我有一个带有工具提示的饼图,其中显示了一些额外的数据。如何获取要与数据表一起导出的数据?

当您点击导出>查看数据表时,我需要将{point.custom}添加为一列

JSFiddle链接: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
     }]
 }]
});

1 个答案:

答案 0 :(得分:1)

您可以通过keys属性添加自定义数据:

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

实时演示:https://jsfiddle.net/BlackLabel/3m82ck5w/

API参考:https://api.highcharts.com/highcharts/series.pie.keys