请参阅下面的代码。如何为x轴标签添加颜色?
Highcharts.chart('container', {
chart: {
type: 'column'
},
credits: {
enabled: false
},
title: {
text: 'Gender Distribution'
},
xAxis: {
categories: ['2017', '2018', '2019', '2020']
},
yAxis: {
min: 0,
title: {
text: ''
}
},
yAxis: [{
labels: {
format: '{value} %'
},
min: 0,
max: 60,
opposite: false
}],
plotOptions: {
column: {
stacking: 'percent'
}
},
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.percentage:.0f}%)<br/>',
shared: true
},
plotOptions: {
column: {
stacking: 'percent'
}
},
series: [{
name: 'Male',
data: [5, 3, 4, 7 ]
}, {
name: 'Female',
data: [2, 2, 3, 2 ]
}]
});
在这里输入代码
编辑:格式代码
答案 0 :(得分:0)
这是一个例子:
const colors = Highcharts.getOptions().colors
const options = {
yAxis: {
labels: {
style: {
color: colors[0]
}
}
},
series: [{
data: [29.9, 71.5, 106.4],
type: 'column'
}]
}
const chart = Highcharts.chart('container', options);