美文网首页
echarts 设置全选、反选

echarts 设置全选、反选

作者: 9c31078a8e66 | 来源:发表于2022-07-22 15:15 被阅读0次
                let selectName = ""
                chart.on('legendselectchanged', function(obj) {
                    const {selected, name} = obj;
                    let status = selected[name]
                    let otherStatus = status
                    for(let key in selected) {
                        if(key != name) {
                            otherStatus = selected[key]
                            break
                        }
                    }
                    if (selectName != name) {
                        otherStatus = true
                    }
                    // 设置状态
                    for(let key in selected) {
                        if(key === name) {
                            selected[key] = true
                        } else {
                            selected[key] = !otherStatus
                        }
                    }
                    option.legend.selected = selected;
                    chart.setOption(option);
                    selectName = name
                });
    

    相关文章

      网友评论

          本文标题:echarts 设置全选、反选

          本文链接:https://www.haomeiwen.com/subject/ocimirtx.html