在使用Echarts图表插件实现树图结构展示,遇到了实现通过图例实现筛选效果,点击某一项对勾勾选,再次点击对勾消失,相应树图中也不再展示相应的信息,这一功能的实现,需要做到1、图例要保持与option中series的name一致;2、要实现图例legend的选择事件,更换图例前方图片,实现展示效果
如上图的勾选效果
1、添加legend属性,保持data中的name属性与series中name保持一致
option = {
animation:false,
addDataAnimation:true,
animationDuration:1000,
legend: {
x: 60,
y:30,
itemWidth: 20,
itemHeight: 20,
orient:'vertical',
//backgroundColor: '#eee',
borderColor: 'rgba(178,34,34,0.8)',
// borderWidth: 1,
textStyle:{