1.问题概要:
在使用pie图的时候需要对label进行格式化显示,官方给的实例中,大量使用未定义,未说明的变量。
我不清楚如何进行数据关联。
2.场景详述:
2.1.链接及简化代码:
链接:https://www.echartsjs.com/exa...
简化代码:
app.title = '嵌套环形图';
option = {
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b}: {c} ({d}%)"
},
legend: {
orient: 'vertical',
x: 'left',
data:['直达','邮件营销','联盟广告']
},
series: [
{
name:'访问来源',
type:'pie',
radius: ['40%', '55%'],
label: {
normal: {
formatter: '{a|{a}}{abg|}\n{hr|}\n {b|{b}:}{c} {per|{d}%} ',
backgroundColor: '#eee',
borderColor: '#aaa',
borderWidth: 1,
borderRadius: 4,
rich: {
a: {
color: '#999',
lineHeight: 22,
align: 'center'
},
hr: {
borderColor: '#aaa',
width: '100%',
borderWidth: 0.5,
height: 0
},
b: {
fontSize: 16,
lineHeight: 33
},
per: {
color: '#eee',
backgroundColor: '#334455',
padding: [2, 4],
borderRadius: 2
}
}
}
},
data:[
{value:335, name:'直达'},
{value:310, name:'邮件营销'},
{value:234, name:'联盟广告'},
]
}
]
};
效果图:
3.具体问题:
图中格式化使用的变量如a,b,c,d,per等。 都是出自哪里的,应该是封装好的内部变量,可是这些变量在官方文档中是否有说明? 在哪里,我真的没找到。 百度能百度到一部分,但是说的很不官方。
感谢!!!
找一下echarts文档就有啦
标签内容格式器,支持字符串模板和回调函数两种形式,字符串模板与回调函数返回的字符串均支持用
\n
换行。字符串模板
字符串模板 模板变量有: