fix crash due to zero or negative data values in graph with log scale

pull/5278/head
bigbenhur 9 years ago
parent 1e4eb01059
commit 29b9d17faa
  1. 6
      public/app/core/time_series2.ts
  2. 7
      public/app/plugins/panel/graph/graph.js

@ -97,6 +97,7 @@ export default class TimeSeries {
this.stats.total = 0;
this.stats.max = -Number.MAX_VALUE;
this.stats.min = Number.MAX_VALUE;
this.stats.logmin = Number.MAX_VALUE;
this.stats.avg = null;
this.stats.current = null;
this.allIsNull = true;
@ -133,6 +134,11 @@ export default class TimeSeries {
if (currentValue < this.stats.min) {
this.stats.min = currentValue;
}
if (currentValue < this.stats.logmin && currentValue > 0) {
this.stats.logmin = currentValue;
}
}
if (currentValue !== 0) {

@ -386,11 +386,12 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
if (max === null || max < series.stats.max) {
max = series.stats.max;
}
if (min === null || min > series.stats.min) {
min = series.stats.min;
if (min === null || min > series.stats.logmin) {
min = series.stats.logmin;
}
}
}
if (max === null && min === null) {
max = Math.pow(axis.logBase,+2);
min = Math.pow(axis.logBase,-2);
@ -400,7 +401,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
min = max*Math.pow(axis.logBase,-4);
}
axis.transform = function(v) { return Math.log(v) / Math.log(axis.logBase); };
axis.transform = function(v) { return (v < Number.MIN_VALUE) ? null : Math.log(v) / Math.log(axis.logBase); };
axis.inverseTransform = function (v) { return Math.pow(axis.logBase,v); };
min = axis.inverseTransform(Math.floor(axis.transform(min)));

Loading…
Cancel
Save