
let xAxisValue1 = [63, 89, 44, 34, 3, 98];
let xAxisValue2 = [23, 89, 44, 34, 3, 98];
option = {
legend: {
data: ['退出项目', '未退出项目'],
bottom: 0
},
title: {
text: '已退出项目占比',
x: 'center',
textAlign: 'center'
},
toolbox: {},
color: ['rgb(116,142,222)', '#AD6D69'],
tooltip: {},
xAxis: {
data: [
'赛用业务线',
'赛用业务线',
'赛用业务线',
'赛用业务线',
'赛用业务线',
'赛用业务线'
],
axisLine: { show: false },
splitLine: { show: false },
splitArea: { show: false },
axisTick: { show: false }
},
yAxis: {
splitLine: { show: false },
axisLabel: { show: false }
},
grid: {
bottom: 100
},
series: [
{
name: '退出项目',
type: 'bar',
stack: 'one',
data: xAxisValue1,
label: {
show: true,
color: '#fff',
formatter: function (a) {
return a.data;
}
},
},
{
name: '未退出项目',
type: 'bar',
stack: 'one',
data: xAxisValue2,
label: {
show: true,
color: '#fff',
formatter: function (a) {
return a.data;
}
},
markPoint: {
symbolSize: 0,
data: formatterMake(xAxisValue1,xAxisValue2),
label: {
show: true,
position: 'top',
color: '#333',
}
}
}
]
};
function formatterMake(v1,v2) {
var arr = new Array();
v1.map(function (item, i) {
arr.push({
coord: [i, v1[i]+v2[i]],
value: Math.round(v1[i]/(v1[i]+v2[i])*100)+'%'
});
});
return arr;
}
echart柱状图堆列实现百分比显示
最新推荐文章于 2024-12-23 23:34:11 发布