legend: {
// 图例位置设置为右上角
right: '0%',
top: '23%',
// 图例布局方向为垂直
orient: 'vertical',
itemGap: 25,
formatter: function (name) {
let data = option.series[0].data;
// console.log(data, 'data')
let total = 0;
let tarValue;
for (let i = 0; i < data.length; i++) {
total += data[i].value;
if (data[i].name == name) {
tarValue = data[i].value;
}
}
let v = tarValue;
let p = Math.round((tarValue / total) * 100); //占比
return `${name} ${v} (${p}%) `;
}
},
01-09
842
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-22
3178
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-03
4127
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)