希望是在一个bar图上, 每个bar的中间和顶部放上一个label,但是在echarts提供的配置项中,单个series只能增加一个label, 所以这里实现时,画了两组 series 来实现(第二组数据全写了0), 想知道 有没有更优雅的实现来完成此需求, 而不是两个 series. 另外, 希望增加多个label的方法在饼图上也能适用.
配置项如下
option = {
title: {
text: '测试',
bottom: '0%',
left: 'center'
},
tooltip: {
show: false
},
grid: {
left: '3%',
right: '4%',
bottom: '10%'
},
xAxis: [{
type: 'category',
data: ['C1', 'C2', 'C3'],
axisTick: {
show: false
},
show: false,
axisLine: {
show: false
},
offset: 0,
position: 'top'
}],
yAxis: [{
show: false,
type: 'value'
}],
series: [{
type: 'bar',
stack: 's1',
barWidth: '44pt',
data: [30, 25, 20],
label: {
normal: {
show: true,
formatter: '{c} %',
color: '#FFFFFF',
fontSize: '15pt'
}
}
}, {
type: 'bar',
stack: 's1',
barWidth: '44pt',
data: [0, 0, 0],
label: {
normal: {
show: true,
formatter: '{b}',
position: 'top',
distance: 10
}
}
}]
};