标签:name type lse batch isp ndt fine def 全选
echarts version: 3.1.2
取消选中
后,自动全选中所有图例。 var triggerAction = function(action, selected) {
legend = [];
for ( name in selected) {
if (selected.hasOwnProperty(name)) {
legend.push({name: name});
}
}
myChart.dispatchAction({
type: action,
batch: legend
});
};
var isFirstUnSelect = function(selected) {
var unSelectedCount = 0;
for ( name in selected) {
if (!selected.hasOwnProperty(name)) {
continue;
}
if (selected[name] == false) {
++unSelectedCount;
}
}
return unSelectedCount==1;
};
var isAllUnSelected = function(selected) {
var selectedCount = 0;
for ( name in selected) {
if (!selected.hasOwnProperty(name)) {
continue;
}
// 所有 selected Object 里面 true 代表 selected, false 代表 unselected
if (selected[name] == true) {
++selectedCount;
}
}
return selectedCount==0;
};
myChart.on(‘legendselectchanged‘, function(obj) {
var selected = obj.selected;
var legend = obj.name;
// 使用 legendToggleSelect Action 会重新触发 legendselectchanged Event,导致本函数重复运行
// 使得 无 selected 对象
if (selected != undefined) {
if (isFirstUnSelect(selected)) {
triggerAction(‘legendToggleSelect‘, selected);
} else if (isAllUnSelected(selected)) {
triggerAction(‘legendSelect‘, selected);
}
}
});
标签:name type lse batch isp ndt fine def 全选
原文地址:https://www.cnblogs.com/shj-com/p/11327072.html