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的指向!

posted @ 2019-06-04 10:20  xiaxuening  阅读(7468)  评论(0编辑  收藏  举报