echarts 图例 自定义点击事件(点击图例反选显示)
this.echart.on('legendselectchanged', function(obj) { const {selected, name} = obj; if (first && selected) { Object.keys(selected).forEach(key => { selected[key] = key === name ? true : false; }); first = false; } else { let open = selected[name]; selected[name] = open; } option.legend.selected = selected; this.setOption(option); });
此代码是在vue的基础上写的,要注意this的指向!