【问题标题】:Change Highchart's pie chart .xls file category column name更改 Highchart 的饼图 .xls 文件类别列名
【发布时间】:2019-03-20 09:29:19
【问题描述】:

我正在使用 Highcharts 饼图,我想下载生成的带有自定义列名称的 .xls 文件。默认情况下,这些列是名称“类别”和“你的系列名称”(在我的例子中是“百分比 (%)”。 主要是想改Category名字,但是没找到办法。

这是图表的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: [
                ]
            }]
        });

.xls file image

the chart

【问题讨论】:

  • 请添加更多细节,包括一些源代码

标签: javascript charts highcharts pie-chart


【解决方案1】:

使用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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-15
    • 2013-06-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多