看Demo,环形图只有当鼠标悬停在环上某一区域,才会在圆环中心显示这一区域的占比; 有没有办法默认就显示某个区域的数值呢?
Demo中的代码:
option = {
tooltip : {
trigger: 'item',
formatter: "{a}
{b} : {c} ({d}%)"
},
legend: {
orient : 'vertical',
x : 'left',
data:['直接访问','邮件营销','联盟广告','视频广告','搜索引擎']
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
restore : {show: true},
saveAsImage : {show: true}
}
},
calculable : true,
series : [
{
name:'访问来源',
type:'pie',
radius : ['50%', '70%'],
itemStyle : {
normal : {
label : {
show : false
},
labelLine : {
show : false
}
},
emphasis : {
label : {
show : true,
position : 'center',
textStyle : {
fontSize : '30',
fontWeight : 'bold'
}
}
}
},
data:[
{value:335, name:'直接访问'},
{value:310, name:'邮件营销'},
{value:234, name:'联盟广告'},
{value:135, name:'视频广告'},
{value:1548, name:'搜索引擎'}
]
}
]
};
itemStyle : {
normal : {
label : {
show : true,
position: 'center',
formatter: '{d}%'
},
labelLine : {
show : false
}
},
label置为true了,可以在中心显示数据; 但多个扇形的数据都在这里重叠了, 有木有办法只显示某一个? 就类似鼠标悬停在某个扇形区域时,中心只显示这个扇形的百分比
label: {
show: true,
position: 'center',
formatter: function(a,b,c,d) {
if(b == '直接访问')
return (d - 0).toFixed(0) + '%'
else
return ''
},
这个只显示一个,不过鼠标悬停的时候中心显示的有重叠(label 和 emphasis); 能不能默认触发emphasis的mouseover?
NND, 没人回
shape = myChart.chart.pie.shapeList[0]
myChart.chart.pie.shapeHandler.onmouseover({'target': shape})
myChart.chart.pie.zr.refreshHover()
搞定
抱歉,前几天比较忙~
太高端,都直接用源码了,还能这样做,没想到:)
如果只是出tooltip,有个showTip接口 http://echarts.baidu.com/doc/doc.html#TooltipInterface