mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Minor refactoring of PR #15770
This commit is contained in:
@@ -919,16 +919,18 @@ export class DashboardModel {
|
||||
}
|
||||
|
||||
toggleLegendsForAll() {
|
||||
const panels = this.panels.filter(panel => {
|
||||
const panelsWithLegends = this.panels.filter(panel => {
|
||||
return panel.legend !== undefined && panel.legend !== null;
|
||||
});
|
||||
|
||||
// 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;
|
||||
panels.forEach(panel => {
|
||||
|
||||
for (const panel of panelsWithLegends) {
|
||||
panel.legend.show = !panelLegendsOn;
|
||||
panel.render();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user