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
});
网友评论