我有一个要求,有一个堆叠百分比列图表,在高图表显示一个具体的百分比数字,而不是一个100%的细分。例如,如果数字是60%,图表应该显示一个60%的细分(20%蓝色,10%绿色,30%黄色),而不是填补高达100%。我对百分比图表的理解是,它们总是100%,但我想知道这种操纵是否可以用高图表来实现?谢谢。
发布于 2016-03-18 18:19:19
就像@Alden所说的那样,使用带有%标签的堆叠列。这是JSFiddle实例。
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Percentage'
},
labels: {
formatter: function () {
return this.value + '%';
}
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
},
formatter: function () {
return this.total + '%';
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}%<br/>Total: {point.stackTotal}%'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
format:'{y}%',
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black'
}
}
}
},
series: [{
name: 'John',
data: [5, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [2, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}]
});
});发布于 2016-03-18 18:14:53
使用堆叠列而不是堆叠百分比列,然后简单地将百分比附加到标签中。“百分比”列自动确定所提供的所有数据点的百分比,听起来您希望该列只是呈现所提供的信息。
https://stackoverflow.com/questions/36090890
复制相似问题