Javascript 如何更改箱线图(highcharts)中各组的颜色
我正在使用Highcharts boxplot=>为此,我希望每个组(每个框)有不同的颜色。 我可以提供系列级别的颜色,但这将改变所有框的颜色。 我想要实现的是每个盒子都有不同的颜色。 寻找实现这一目标的最佳途径 请看一看Javascript 如何更改箱线图(highcharts)中各组的颜色,javascript,highcharts,boxplot,Javascript,Highcharts,Boxplot,我正在使用Highcharts boxplot=>为此,我希望每个组(每个框)有不同的颜色。 我可以提供系列级别的颜色,但这将改变所有框的颜色。 我想要实现的是每个盒子都有不同的颜色。 寻找实现这一目标的最佳途径 请看一看 Highcharts.chart('container', { chart: { type: 'boxplot' }, title: { text: 'Highcharts Box Plot Example' }, legend: { enabl
Highcharts.chart('container', {
chart: {
type: 'boxplot'
},
title: {
text: 'Highcharts Box Plot Example'
},
legend: {
enabled: false
},
xAxis: {
categories: ['1', '2', '3', '4', '5'],
title: {
text: 'Experiment No.'
}
},
yAxis: {
title: {
text: 'Observations'
},
plotLines: [{
value: 932,
color: 'red',
width: 1,
label: {
text: 'Theoretical mean: 932',
align: 'center',
style: {
color: 'gray'
}
}
}]
},
series: [{
name: 'Observations',
data: [
[760, 801, 848, 895, 965],
[733, 853, 939, 980, 1080],
[714, 762, 817, 870, 918],
[724, 802, 806, 871, 950],
[834, 836, 864, 882, 910]
],
tooltip: {
headerFormat: '<em>Experiment No {point.key}</em><br/>'
}
}, {
name: 'Outlier',
color: Highcharts.getOptions().colors[0],
type: 'scatter',
data: [ // x, y positions where 0 is the first category
[0, 644],
[4, 718],
[4, 951],
[4, 969]
],
marker: {
fillColor: 'white',
lineWidth: 1,
lineColor: Highcharts.getOptions().colors[0]
},
tooltip: {
pointFormat: 'Observation: {point.y}'
}
}]
Highcharts.chart('container'{
图表:{
类型:“箱线图”
},
标题:{
文本:“Highcharts方框图示例”
},
图例:{
已启用:false
},
xAxis:{
类别:['1','2','3','4','5'],
标题:{
文本:“实验号”
}
},
亚克斯:{
标题:{
案文:“观察”
},
绘图线:[{
价值:932,
颜色:“红色”,
宽度:1,
标签:{
正文:“理论平均值:932”,
对齐:'居中',
风格:{
颜色:“灰色”
}
}
}]
},
系列:[{
名称:'观察',
数据:[
[760, 801, 848, 895, 965],
[733, 853, 939, 980, 1080],
[714, 762, 817, 870, 918],
[724, 802, 806, 871, 950],
[834, 836, 864, 882, 910]
],
工具提示:{
headerFormat:“实验编号{point.key}
”
}
}, {
名称:“异常值”,
颜色:Highcharts.getOptions().color[0],
键入:“散布”,
数据:[/x,y位置,其中0是第一个类别
[0, 644],
[4, 718],
[4, 951],
[4, 969]
],
标记:{
fillColor:'白色',
线宽:1,
lineColor:Highcharts.getOptions().Color[0]
},
工具提示:{
pointFormat:'观测:{point.y}'
}
}]
}))
谢谢经过研究,我找到了答案
plotOptions: {
series: {
colorByPoint: true
}
}
感谢我能够做到这一点,为每个盒子创建一个新的系列,然后为每个系列应用不同的颜色,但要管理x轴类别,我必须添加一些空阵列。。我不喜欢。