我有一个通过Highcharts呈现的柱形图,其中包含多个类别和多个系列。虽然Highcharts慷慨地按类别对系列数据进行分组和对齐,但似乎没有一个配置选项允许为类别分组设置背景颜色。
我想按类别实现斑马条纹,就像我在Photoshop®中制作的粗糙模型一样:
这是jsfiddle containing my current code和我当前的图表配置:
var chartOptions = {
"chart": {
"type": "column"
},
"title": {
"text": ""
},
"credits": {
"enabled": false
},
"subtitle": {
"text": ""
},
"xAxis": {
"categories": [
"Category 1",
"Category 2",
"Category 3",
"Category 4",
"Category 5",
"Category 6"
],
"opposite": true
},
"yAxis": {
"title": {
"text": "Score"
},
"tickPixelInterval": 40
},
"plotOptions": {
"column": {
"pointPadding": 0.2,
"borderWidth": 0
}
},
"series": [
{
"name": "Series 1",
"data": [22.735, 5.9, -18.71, -41.17, -0.865, -6.03]
},
{
"name": "Series 2",
"data": [20.67, 5.46, -17.15, -37.66, -0.79, -5.52]
},
{
"name": "Series 3",
"data": [29, 2, -20, -29, -2, 16]
}
]
};
答案 0 :(得分:5)
您可以使用xAxis
上的alternateGridColor
选项:
"xAxis": {
"categories": [
"Category 1",
"Category 2",
"Category 3",
"Category 4",
"Category 5",
"Category 6"
],
"opposite": true,
alternateGridColor: '#CCC'
如果查看xAxis
documentation,可以使用相当多的不同属性。