Echarts环形图--自定义图例文本和中心文字
legend: {
orient: 'vertical',
icon: "circle",
top: `${this.top}`,
right: '5%',
data: ["正常","异常","故障","一键报警","离线"],
formatter: function(name){
let target;
for(let i=0;i<list.length;i++){
if(list[i].deviceStatus==name){
target = list[i].proportion+'% ('+ list[i].count + ')'
}
}
let arr = [name+":"+target]
return arr
}
},
graphic: [{//环形图中间添加文字
type: 'text',//通过不同top值可以设置上下显示
left: '14%',
top: '28%',
style: {
text: "接入数",
textAlign: 'center',
fill: '#AEAEB7',//文字的颜色
width: 30,
height: 30,
fontSize: 13,
color: "#AEAEB7",
fontFamily: "Microsoft YaHei"
}
}, {
type: 'text',
left: '14%',
top: '37%',
style: {
text: `${this.total}`,
textAlign: 'center',
fill: '#000',
width: 30,
height: 30,
fontSize: 15,
fontWeight: 'bold'
}
}],