echarts饼图添加点击事件及相关问题
1.饼图点击事件会触发两次myChart.off('click’)// 取消之前的点击事件//添加点击事件myChart.on('click',(a,b)=>{console.log(a)})2.可以通过点击事件 查询当前饼图是裂开还是合上的状态a.event.target.parent._children是饼图的对象数组selected为true代表当前为选中状态,反之未选中3.echar
·
1.饼图点击事件会触发两次
myChart.off('click’) // 取消之前的点击事件
//添加点击事件
myChart.on('click',(a,b)=>{
console.log(a)
})
2.可以通过点击事件 查询当前饼图是裂开还是合上的状态
a.event.target.parent._children是饼图的对象数组
数组中selected为true代表当前为选中状态,反之未选中
3.echarts的legend事件禁用以及legend显示百分比
legend: {
orient: "vertical",
left: 'center',
top:'73%',
selectedMode: false, //legend事件禁用
// legend显示百分比
formatter: (name)=> {
var total = 0
var tarValue
for(let i of this.topStreetArr) {
total += i.value
if (i.name === name) {
tarValue = i.value
}
}
if(tarValue){
var rate = ((tarValue / total) * 100).toFixed(0)
return name + " " + " " + rate + "%"
}else{
return name+ " "
}
},
},
更多推荐
已为社区贡献1条内容
所有评论(0)