Fix NaN handling (#9469)

* graph: fix NaN formatting, #9012

* singlestat: prevent null value coloring, #9012, #8404

* timeseries: add tests for #9012 and move test file to TS
This commit is contained in:
Alexander Zobnin
2017-10-10 15:25:57 +03:00
committed by Torkel Ödegaard
parent 473c47cd1c
commit 3184942aeb
4 changed files with 307 additions and 280 deletions

View File

@@ -203,7 +203,7 @@ export default class TimeSeries {
if (this.stats.max === -Number.MAX_VALUE) { this.stats.max = null; }
if (this.stats.min === Number.MAX_VALUE) { this.stats.min = null; }
if (result.length) {
if (result.length && !this.allIsNull) {
this.stats.avg = (this.stats.total / nonNulls);
this.stats.current = result[result.length-1][1];
if (this.stats.current === null && result.length > 1) {
@@ -228,6 +228,9 @@ export default class TimeSeries {
}
formatValue(value) {
if (!_.isFinite(value)) {
value = null; // Prevent NaN formatting
}
return this.valueFormater(value, this.decimals, this.scaledDecimals);
}