【发布时间】:2020-10-21 02:42:38
【问题描述】:
我正在使用按列分组的高图表。前任: https://jsfiddle.net/2bvudw1m/
有没有一种方法可以显示代表y 计数(列系列顶部)和列的dataLabel 名称(底部)的数据标签?
例如:这是我的系列数据:
series: [{
name: 'active',
data: [53, 33, 43, 63, 7, 83],
dataLabels: {
enabled: true,
verticalAlign: 'bottom',
overflow: 'none',
crop: false,
y: 20,
formatter() {
return this.series.userOptions.name;
}
}
}, {
name: 'new',
data: [33, 43, 43, 63, 73, 8],
}]
我想展示两件事:
- 计数代表每个系列
- 该系列的DataLabel
到目前为止,我有这个:
$(function() {
$('#container').highcharts({
chart: {
type: 'column',
},
title: {
text: 'Total fruit consumtion, grouped by gender'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Apples2', 'Oranges2','Apples3', 'Apple33'],
offset: 30
},
yAxis: {
allowDecimals: false,
//offset:10,
title: {
text: 'Number of fruits'
},
stackLabels: {
enabled: true,
verticalAlign: 'top',
}
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
formatter: function() {
return this.y;
}
}
},
column: {
stacking: ''
},
},
series: [{
name: 'active',
data: [53, 33, 43, 63, 7, 83],
dataLabels: {
enabled: true,
verticalAlign: 'bottom',
overflow: 'none',
crop: false,
y: 20,
formatter() {
return this.series.userOptions.name;
}
}
}, {
name: 'new',
data: [33, 43, 43, 63, 73, 8],
}
]
});
});
https://jsfiddle.net/nec89t56/2/
但是这不起作用,因为当我尝试添加两个值时,它要么添加 y 计数或名称。当列为grouped: true 和stacking: "" 时,有没有办法同时添加两者
注意:我不能像“正常”那样进行堆叠,因为它会堆叠而不是分组,这不是我想要的。
有什么想法吗?
【问题讨论】:
标签: javascript highcharts