gpt4 book ai didi

highcharts - Highcharts 列标签

转载 作者:行者123 更新时间:2023-12-03 23:36:41 28 4
gpt4 key购买 nike

我制作了一个带有分组和堆叠列的Highcharts图表,就像在这里的示例http://www.highcharts.com/demo/column-stacked-and-grouped一样。该示例显示了按性别分组的5个不同人的许多水果。在此示例中,我错过了一个x轴标签,该标签显示了每个组下方的组名(男性或女性)。可以将其添加到图表中吗?

这是我要制作的图表的简化版本:http://jsfiddle.net/WQjVP/66/。它显示了案件处理系统中三个位置的未解决(蓝色)和过期(红色)问题的数量。每组的左列显示的是该位置在7月的数字,每组的右列显示的是同一单位在8月的数字。我想做的是在每一列下显示月份,这样第一列将具有“Jul”,第二列将具有“Aug”,第三列将具有“Jul”,依此类推,在该列和位置标签。

chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories: ["Location A","Location B","Location C"],
title: {
text: "Location"
}
},
yAxis: {
allowDecimals: false

},
plotOptions: {
series: {
dataLabels: {
enabled: true,
formatter: function() {
if (this.y === 0) {
return null;
}
return this.y;
},
style: {
color: 'white'
}
}
},
column: {
stacking: 'normal',
borderWidth: 0
}
},
series: [{
"color": "rgb(0,0,255)",
"name": "open",
"data": [18, 2, 6],
"stack": "Jul"},
{
"color": "rgb(255,0,0)",
"name": "overdue",
"data": [0, 0, 0],
"stack": "Jul"},
{
"color": "rgb(0, 0, 255)",
"name": "open",
"data": [20, 1, 10],
"stack": "Aug"},
{
"color": "rgb(255, 0, 0)",
"name": "overdue",
"data": [2, 1, 2],
"stack": "Aug"
}]
});

最佳答案

尝试使用stackedLabels

yAxis: {
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: 'gray'
},
formatter: function() {
return this.stack;
}
}
}

Demo

reference

关于highcharts - Highcharts 列标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12197047/

28 4 0