Browse Source

Graph: New legend option hideEmtpy to hide series with only null values from legend, Closes #1028

Torkel Ödegaard 11 years ago
parent
commit
846cf934f5
3 changed files with 10 additions and 0 deletions
  1. 3 0
      CHANGELOG.md
  2. 1 0
      src/app/panels/graph/axisEditor.html
  3. 6 0
      src/app/panels/graph/legend.js

+ 3 - 0
CHANGELOG.md

@@ -1,5 +1,8 @@
 # 1.9.1 (unreleased)
 
+**Enhancements**
+- [Issue #1028](https://github.com/grafana/grafana/issues/1028). Graph: New legend option ``hideEmtpy`` to hide series with only null values
+
 **Fixes**
 - [Issue #1199](https://github.com/grafana/grafana/issues/1199). Graph: fix for series tooltip when one series is hidden/disabled
 - [Issue #1207](https://github.com/grafana/grafana/issues/1207). Graphite: movingAverage / movingMedian parameter type impovement, now handles int and interval parameter

+ 1 - 0
src/app/panels/graph/axisEditor.html

@@ -44,6 +44,7 @@
 		<editor-opt-bool text="Values" model="panel.legend.values" change="render()"></editor-opt-bool>
 		<editor-opt-bool text="Table" model="panel.legend.alignAsTable" change="render()"></editor-opt-bool>
 		<editor-opt-bool text="Right side" model="panel.legend.rightSide" change="render()"></editor-opt-bool>
+		<editor-opt-bool text="Hide empty" model="panel.legend.hideEmpty" tip="Hides series with only null values" change="render()"></editor-opt-bool>
 	</div>
 
   <div class="section" ng-if="panel.legend.values">

+ 6 - 0
src/app/panels/graph/legend.js

@@ -125,6 +125,12 @@ function (angular, app, _, kbn, $) {
 
           for (i = 0; i < seriesList.length; i++) {
             var series = seriesList[i];
+
+            // ignore empty series
+            if (panel.legend.hideEmpty && series.allIsNull) {
+              continue;
+            }
+
             var html = '<div class="graph-legend-series';
             if (series.yaxis === 2) { html += ' pull-right'; }
             if (scope.hiddenSeries[series.alias]) { html += ' graph-legend-series-hidden'; }