思路
通过设置legend里textstyle里的rich
具体代码
let objData2 = {'当前旅客':{
"name": "当前旅客",
"value": 200
},'旅客':{
"name": "旅客",
"value": 2000
}}
legend: {
orient: 'vertical',
right: '10%',
top: 'middle',
show: true,
itemWidth: 25,
itemHeight: 14,
// align: 'top',
icon: "circle",
formatter: function (name: string | number) {///这里
return `{percent|${objData2[name].value}}` + '\n' + `{a| ${name}}`///这里
}
textStyle: {
color: '#B9B8CE',
fontSize: 12,
borderWidth: 'auto',
rich: {///这里
percent: {///这里
color: '#fff',
fontSize: 30,
lineHeight: 43,
fontWeight: ''
},
a: {///这里
color: '#ABD2F8FF',
fontSize: 12,
fontWeight: 100
}
}
}
}