Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pie用dataset设置数据,tooltip模板显示值显示为对象而不是数字 #9315

Closed
shuxinyun opened this issue Oct 31, 2018 · 2 comments

Comments

@shuxinyun
Copy link

var option={
type: 0,
title: {
text: "本页引用部件",
left: "center"
},
tooltip: {
trigger: "item",
formatter: "{a}
{b}: {c} ({d}%)"
},
dataset:[{
id:"shufu",
dimensions: ['category','count'],
source:[{category:"直达",count:335}, {category:"营销广告",count:679},{category:"搜索引擎",count:1548}]
},{
id:"duoer",
dimensions: ['name','value'],
source:[
{count:1,value: 335,name: "直达",selected:true },
{count:2,value: 310,name: "邮件营销"},
{count:3,value: 234,name: "联盟广告"},
{count:4,value: 135,name: "视频广告"},
{count:5,value: 1048,name: "百度"},
{count:6,value: 251,name: "谷歌"},
{count:7,value: 147,name: "必应"},
{count:8,value: 102,name: "其他"}
]
}],
series: [{
id:"shufu",
name: "访问来源",
type: "pie",
radius: ["0", "30%"],
selectedMode: "single",
label: {
normal: {
position: "inner"
}
},
labelLine: {
normal: {
show: false
}
},
datasetIndex:0
}, {
id:"duoer",
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
}
}
}
},
labelLine: {
normal: {
show: true
}
},
datasetIndex:1
}]
};

@shuxinyun
Copy link
Author

default
()

@sxmpasch
Copy link

It looks like the {c} reference in the formatter is referring to the whole object instead of the mapped value. In this case, it is e.g."{count:6,value: 251,name: "谷歌"}.

You can see the same behaviour here: https://ecomfe.github.io/echarts-examples/public/editor.html?c=dataset-default
if you add formatter: "{a} {b}: {c} ({d}%)"
to the tooltip area, you get the same results (here the whole line in the underlying array is displayed...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants