From 1f57cf08a7e63539b6d8d930205919f3ea156650 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 25 Nov 2015 04:38:54 -0800 Subject: [PATCH] Added an option to hide zero values --- public/app/core/time_series.ts | 6 ++++++ public/app/panels/graph/axisEditor.html | 3 +++ public/app/panels/graph/graph.tooltip.js | 5 +++++ public/app/panels/graph/legend.js | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/public/app/core/time_series.ts b/public/app/core/time_series.ts index 0fb2b83b7e0..429e3882e8b 100644 --- a/public/app/core/time_series.ts +++ b/public/app/core/time_series.ts @@ -28,6 +28,7 @@ class TimeSeries { stats: any; legend: boolean; allIsNull: boolean; + allIsZero: boolean; decimals: number; scaledDecimals: number; @@ -96,6 +97,7 @@ class TimeSeries { this.stats.avg = null; this.stats.current = null; this.allIsNull = true; + this.allIsZero = true; var ignoreNulls = fillStyle === 'connected'; var nullAsZero = fillStyle === 'null as zero'; @@ -130,6 +132,10 @@ class TimeSeries { } } + if (currentValue != 0) { + this.allIsZero = false; + } + result.push([currentTime, currentValue]); } diff --git a/public/app/panels/graph/axisEditor.html b/public/app/panels/graph/axisEditor.html index 41ea8dd3696..e2bc4d36b1d 100644 --- a/public/app/panels/graph/axisEditor.html +++ b/public/app/panels/graph/axisEditor.html @@ -167,6 +167,9 @@
  • +
  • + +
  • diff --git a/public/app/panels/graph/graph.tooltip.js b/public/app/panels/graph/graph.tooltip.js index 8a747b61e0c..c56d7ce8c30 100644 --- a/public/app/panels/graph/graph.tooltip.js +++ b/public/app/panels/graph/graph.tooltip.js @@ -52,6 +52,11 @@ function ($) { continue; } + if (!series.data.length || (scope.panel.legend.hideZero && series.allIsZero)) { + results.push({ hidden: true }); + continue; + } + hoverIndex = this.findHoverIndexFromData(pos.x, series); results.time = series.data[hoverIndex][0]; diff --git a/public/app/panels/graph/legend.js b/public/app/panels/graph/legend.js index 065e74fed30..8604dff4f08 100644 --- a/public/app/panels/graph/legend.js +++ b/public/app/panels/graph/legend.js @@ -137,6 +137,10 @@ function (angular, _, $) { if (!series.legend) { continue; } + // ignore zero series + if (panel.legend.hideZero && series.allIsZero) { + continue; + } var html = '