Commit 0cba8183 by Torkel Ödegaard

Graph: legend and digest phase fix

parent 4285c751
...@@ -10,6 +10,7 @@ function (_, kbn) { ...@@ -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) { ...@@ -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.stats.total = 0;
this.info.max = -212312321312; this.stats.max = -212312321312;
this.info.min = 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) { ...@@ -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) { if (currentValue > this.stats.max) {
this.info.max = currentValue; this.stats.max = currentValue;
} }
if (currentValue < this.info.min) { if (currentValue < this.stats.min) {
this.info.min = currentValue; 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.stats.avg = (this.stats.total / result.length);
this.info.current = result[result.length-1][1]; this.stats.current = result[result.length-1][1];
} }
return result; return result;
...@@ -113,11 +114,11 @@ function (_, kbn) { ...@@ -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.avg = this.formatValue(this.stats.avg);
this.info.current = this.formatValue(this.info.current); this.info.current = this.formatValue(this.stats.current);
this.info.min = this.formatValue(this.info.min); this.info.min = this.formatValue(this.stats.min);
this.info.max = this.formatValue(this.info.max); this.info.max = this.formatValue(this.stats.max);
this.info.total = this.formatValue(this.info.total); this.info.total = this.formatValue(this.stats.total);
}; };
TimeSeries.prototype.formatValue = function(value) { TimeSeries.prototype.formatValue = function(value) {
......
...@@ -111,6 +111,7 @@ function (angular, $, kbn, moment, _, GraphTooltip) { ...@@ -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(); }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment