如何将各部分的占比显示在图例的后面
配置项如下
option = {
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b}: {c} ({d}%)"
},
title: {
text: "老师",
x: 'center',
y: 10,
textStyle: {
fontSize: 14,
fontWeight: 'normal',
color: '#b8eefe' // 主标题文字颜色
},
},
legend: {
orient: 'vertical',
x: 'center',
y: 'bottom',
data: ['教导员', '教师'],
padding: 1,
textStyle: {
fontSize: 12,
color: '#b8eefe',
},
itemWidth: 20,
itemHeight: 20,
// formatter:function (name) { //用来格式化图例文本,支持字符串模板和回调函数两种形式。模板变量为图例名称 {name}
// return name + "{b}: {c} ({d}%)";
// },
},
series: [{
name: '师资情况',
type: 'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'left'
},
emphasis: {
show: false, //中间提示文本
textStyle: {
fontSize: '14',
fontWeight: 'bold'
}
}
},
markLine: {
show: true
},
labelLine: {
normal: {
show: false
}
},
data: [{
value: 13,
name: '教导员',
itemStyle: {
color: '#edf049'
}
},
{
value: 87,
name: '教师',
itemStyle: {
color: '#0cb5ec'
}
}
]
}]
};;
if (option && typeof option === "object") {
myChart.setOption(option, true);
}