Преглед изворни кода

Graph: legend and digest phase fix

Torkel Ödegaard пре 11 година
родитељ
комит
0cba818364
2 измењених фајлова са 18 додато и 16 уклоњено
  1. 17 16
      src/app/components/timeSeries.js
  2. 1 0
      src/app/directives/grafanaGraph.js

+ 17 - 16
src/app/components/timeSeries.js

@@ -10,6 +10,7 @@ function (_, kbn) {
     this.info = opts.info;
     this.info = opts.info;
     this.label = opts.info.alias;
     this.label = opts.info.alias;
     this.valueFormater = kbn.valueFormats.none;
     this.valueFormater = kbn.valueFormats.none;
+    this.stats = {};
   }
   }
 
 
   function matchSeriesOverride(aliasOrRegex, seriesAlias) {
   function matchSeriesOverride(aliasOrRegex, seriesAlias) {
@@ -61,9 +62,9 @@ function (_, kbn) {
     this.color = this.info.color;
     this.color = this.info.color;
     this.yaxis = this.info.yaxis;
     this.yaxis = this.info.yaxis;
 
 
-    this.info.total = 0;
-    this.info.max = -212312321312;
-    this.info.min = 212312321312;
+    this.stats.total = 0;
+    this.stats.max = -212312321312;
+    this.stats.min = 212312321312;
 
 
     var ignoreNulls = fillStyle === 'connected';
     var ignoreNulls = fillStyle === 'connected';
     var nullAsZero = fillStyle === 'null as zero';
     var nullAsZero = fillStyle === 'null as zero';
@@ -82,27 +83,27 @@ function (_, kbn) {
       }
       }
 
 
       if (_.isNumber(currentValue)) {
       if (_.isNumber(currentValue)) {
-        this.info.total += currentValue;
+        this.stats.total += currentValue;
       }
       }
 
 
-      if (currentValue > this.info.max) {
-        this.info.max = currentValue;
+      if (currentValue > this.stats.max) {
+        this.stats.max = currentValue;
       }
       }
 
 
-      if (currentValue < this.info.min) {
-        this.info.min = currentValue;
+      if (currentValue < this.stats.min) {
+        this.stats.min = currentValue;
       }
       }
 
 
       result.push([currentTime * 1000, currentValue]);
       result.push([currentTime * 1000, currentValue]);
     }
     }
 
 
     if (result.length > 2) {
     if (result.length > 2) {
-      this.info.timeStep = result[1][0] - result[0][0];
+      this.stats.timeStep = result[1][0] - result[0][0];
     }
     }
 
 
     if (result.length) {
     if (result.length) {
-      this.info.avg = (this.info.total / result.length);
-      this.info.current = result[result.length-1][1];
+      this.stats.avg = (this.stats.total / result.length);
+      this.stats.current = result[result.length-1][1];
     }
     }
 
 
     return result;
     return result;
@@ -113,11 +114,11 @@ function (_, kbn) {
     this.decimals = decimals;
     this.decimals = decimals;
     this.scaledDecimals = scaledDecimals;
     this.scaledDecimals = scaledDecimals;
 
 
-    this.info.avg = this.formatValue(this.info.avg);
-    this.info.current = this.formatValue(this.info.current);
-    this.info.min = this.formatValue(this.info.min);
-    this.info.max = this.formatValue(this.info.max);
-    this.info.total = this.formatValue(this.info.total);
+    this.info.avg = this.formatValue(this.stats.avg);
+    this.info.current = this.formatValue(this.stats.current);
+    this.info.min = this.formatValue(this.stats.min);
+    this.info.max = this.formatValue(this.stats.max);
+    this.info.total = this.formatValue(this.stats.total);
   };
   };
 
 
   TimeSeries.prototype.formatValue = function(value) {
   TimeSeries.prototype.formatValue = function(value) {

+ 1 - 0
src/app/directives/grafanaGraph.js

@@ -111,6 +111,7 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
             var axis = yaxis[series.yaxis - 1];
             var axis = yaxis[series.yaxis - 1];
             var formater = kbn.valueFormats[scope.panel.y_formats[series.yaxis - 1]];
             var formater = kbn.valueFormats[scope.panel.y_formats[series.yaxis - 1]];
             series.updateLegendValues(formater, axis.tickDecimals, axis.scaledDecimals);
             series.updateLegendValues(formater, axis.tickDecimals, axis.scaledDecimals);
+            if(!scope.$$phase) { scope.$digest(); }
           }
           }
         }
         }