浏览代码

Minor refactoring of PR #15770

Torkel Ödegaard 6 年之前
父节点
当前提交
2604e9e433
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. 7 5
      public/app/features/dashboard/state/DashboardModel.ts

+ 7 - 5
public/app/features/dashboard/state/DashboardModel.ts

@@ -919,16 +919,18 @@ export class DashboardModel {
   }
   }
 
 
   toggleLegendsForAll() {
   toggleLegendsForAll() {
-    const panels = this.panels.filter(panel => {
+    const panelsWithLegends = this.panels.filter(panel => {
       return panel.legend !== undefined && panel.legend !== null;
       return panel.legend !== undefined && panel.legend !== null;
     });
     });
+
     // determine if more panels are displaying legends or not
     // determine if more panels are displaying legends or not
-    const onCount = panels.filter(panel => panel.legend.show).length;
-    const offCount = panels.length - onCount;
+    const onCount = panelsWithLegends.filter(panel => panel.legend.show).length;
+    const offCount = panelsWithLegends.length - onCount;
     const panelLegendsOn = onCount >= offCount;
     const panelLegendsOn = onCount >= offCount;
-    panels.forEach(panel => {
+
+    for (const panel of panelsWithLegends) {
       panel.legend.show = !panelLegendsOn;
       panel.legend.show = !panelLegendsOn;
       panel.render();
       panel.render();
-    });
+    }
   }
   }
 }
 }