legend: { type: 'plain', orient: 'vertical', left: '65%', top: 'center', align: 'left', itemGap: 6, itemWidth: 12, itemHeight: 12, icon: 'circle', symbolKeepAspect: false, formatter: function (name) { let data = option.series[0].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}` }, }