想要实现以下功能
echerts 圆饼图 legend中的data始终和 series中的data的name对应,
以下是代码
let option = {
title : {
text: '会员结构分析(180天内)',
subtext: '纯属虚构',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
top: '40%',
right: 'right',
formatter: {name},
data: ['潜在会员','新会员','活跃会员','沉睡会员','流失会员']
},
series : [
{
name: '会员结构分析',
type: 'pie',
radius : '55%',
center: ['50%', '60%'],
data:[
{value:335, name:'潜在会员'},
{value:310, name:'新会员'},
{value:234, name:'活跃会员'},
{value:135, name:'沉睡会员'},
{value:1548, name:'流失会员'}
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};