highcharts 如何反转(转置)HTML表格的行和列,这是动态生成的高脚椅在Angular 12?

lzfw57am  于 2022-11-11  发布在  Highcharts
关注(0)|答案(1)|浏览(342)

https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/export-data/showtable/
在上面的例子中,我已经使用下面的代码创建了highchart表。

Highcharts.chart('container', {

title: {
    text: 'Solar Employment Growth by Sector, 2010-2016'
},

subtitle: {
    text: 'A demo of displaying a data table in Highcharts'
},

credits: {
    text: 'Source: thesolarfoundation.com'
},

chart: {
    borderWidth: 1,
    borderColor: '#ccc',
    spacingBottom: 30
},

yAxis: {
    title: {
        text: 'Number of Employees'
    }
},
legend: {
    layout: 'vertical',
    align: 'right',
    verticalAlign: 'middle'
},

plotOptions: {
    series: {
        pointStart: 2010
    }
},

series: [{
    name: 'Installation',
    data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
}, {
    name: 'Manufacturing',
    data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
}, {
    name: 'Sales & Distribution',
    data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387]
}, {
    name: 'Project Development',
    data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227]
}, {
    name: 'Other',
    data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
}],

exporting: {
    showTable: true
}

});

在上述部分中,

exporting: {
        showTable: true
    }

这个部分负责生成highchart数据表。我得到的表应该被还原,即行到列,列到行。
我已经尝试过使用javascript dom操作来转换它,但是我只需要一些针对highchart的特定方法。

y0u0uwnf

y0u0uwnf1#

在API中,只有在导出表格时才有行和列的切换功能。在模块data data.switchRowsAndColumns中,所有数据都有可能发生变化,但我认为这不是你的情况。
你可以尝试改变核心和使用扩展方法how to extending Highcharts
https://code.highcharts.com/modules/export-data.src.js中找到这个Chart.prototype.getTableAST
旧版本示例显示了如何 Package 核心并更改导出时创建表的方式:https://jsfiddle.net/BlackLabel/npwjxkuL/

相关问题