Javascript 我试图给X轴标签添加颜色,但没有成功
请看下面我的代码。如何向x轴标签添加颜色Javascript 我试图给X轴标签添加颜色,但没有成功,javascript,highcharts,Javascript,Highcharts,请看下面我的代码。如何向x轴标签添加颜色 Highcharts.chart('container', { chart: { type: 'column' }, credits: { enabled: false }, title: { text: 'Gender Distribution' }, xAxis: { categories: ['2017', '2018', '2019', '2020'] }, yAxis: { m
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 ]
}]
});
Highcharts.chart('container'{
图表:{
类型:“列”
},
学分:{
已启用:false
},
标题:{
案文:“性别分布”
},
xAxis:{
类别:[‘2017’、‘2018’、‘2019’、‘2020’]
},
亚克斯:{
分:0,,
标题:{
文本:“”
}
},
亚克斯:[{
标签:{
格式:“{value}%”
},
分:0,,
最高:60,
反面:错
}],
打印选项:{
专栏:{
堆叠:“百分比”
}
},
工具提示:{
pointFormat:“{series.name}:{point.y}({point.percentage:.0f}%)
”,
分享:真的
},
打印选项:{
专栏:{
堆叠:“百分比”
}
},
系列:[{
姓名:'男',
数据:[5,3,4,7]
}, {
姓名:'女',
数据:[2,2,3,2]
}]
});
在此处输入代码编辑:格式代码这里是一个示例:
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);
我想更改系列的颜色。在哪里可以添加颜色如果要更改系列的颜色,可以在“系列对象”中指定。我想更改x轴的男性和女性颜色。谢谢#stpoacan我可以添加准确的颜色吗男:#4472C4和feamle:#ed7d31我正在添加字符串,但它不起作用。你能在jsfiddle中使用并发送我想要的颜色吗?请使用男和女两种颜色