问题:想要设置如上图的legend icon 的不同样式;
答:legend 以数组形式,分别对其设定相关属性,文字的居中对其等;
legend: [{
data: ['本企业'],
right: "30%",
itemHeight: ecahrtPx(12),
formatter: (name) => {
return '{a|' + name + '}'
},
textStyle: {
rich: {
a: {
fontSize: ecahrtPx(12),
padding: [0, 0, ecahrtPx(2), 0]
},
}
}
},
{
data: ['地区均值'],
right: "5%",
itemWidth: ecahrtPx(12),
itemHeight: ecahrtPx(12),
formatter: (name) => {
return '{a|' + name + '}'
},
textStyle: {
rich: {
a: {
fontSize: ecahrtPx(12),
padding: [0, 0, ecahrtPx(2), 0]
},
}
}
}
],
注:ecahrtPx是转换单位的函数