outchart1.on('legendselectchanged', function(obj) {
var selected = obj.selected;
var name = obj.name;
var trueNum = 0;
var lengthArr = [];
if (selected != undefined) {
for (x in selected) {
//判断是否有选中
if (selected[x]) {
trueNum++;
}
lengthArr.push({
'name': x
});
if (x == name) {
outchart1.dispatchAction({
type: 'legendSelect',
name: x
})
} else {
outchart1.dispatchAction({
type: 'legendUnSelect',
name: x
})
}
}
//如果一个选中的都没有,则显示全部
if (trueNum == 0) {
outchart1.dispatchAction({
type: 'legendSelect',
// 图例名称
batch: lengthArr
})
}
}
})