我正在使用Highcharts的饼图,我想下载生成的.xls文件与自定义列名称。默认情况下,列是名称“类别”和“您的系列名称”(在我的情况下,它是'百分比(%)'。主要是我想更改类别名称,但找不到方法。
这是图表的javascript代码:
janChart = Highcharts.chart('January', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Applications BW Usage in January, 2019'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
size:'80%',
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
},
connectorColor: 'silver'
}
}
},
series: [{
name: 'Percentage (%)',
data: [
]
}]
});
使用columnHeaderFormatter
函数:
exporting: {
csv: {
columnHeaderFormatter: function(item, key) {
if (!key) {
return 'custom title'
}
return false
}
}
},
现场演示:https://jsfiddle.net/BlackLabel/n6oLmyw3/
API参考:https://api.highcharts.com/highcharts/exporting.csv.columnHeaderFormatter