我有以下 HighChart 代码。我想通过对象而不是硬编码来提供数据和类别,以便稍后我可以动态获取数据并分配给对象。请让我知道为此需要进行的必要更改。提前致谢。
$('#stackedChartContainer').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
categories: ['IAS', 'Funding', 'Gilts', 'BuyOut']
},
yAxis: {
min: 0,
title: {
text: 'Millions'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -100,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function () {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
}
},
series: [{
name: 'Pensioners',
data: [800000000, 904080340, 961576651, 998929115]
}, {
name: 'Deferreds',
data: [700000000, 925466733, 1063478804, 1158224555]
}, {
name: 'Active',
data: [200000000, 265524863, 305739877, 333386521]
}]
});