echarts legend custom click event (click on the legend invert the selection display)

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);
            });

This code is written on the basis of vue, pay attention to this point!

Guess you like

Origin www.cnblogs.com/xiaxuening/p/10971983.html