Merge pull request #600 from prometheus/fix-special-graph-values

More fixes around special values in graphs.
This commit is contained in:
Julius Volz 2015-03-19 16:55:54 +01:00
commit 3c473c635b
2 changed files with 14 additions and 11 deletions

View file

@ -384,16 +384,17 @@ Prometheus.Graph.prototype.metricToTsName = function(labels) {
}; };
Prometheus.Graph.prototype.parseValue = function(value) { Prometheus.Graph.prototype.parseValue = function(value) {
if (value == "NaN" || value == "Inf" || value == "-Inf") { var val = parseFloat(value);
// Can't display these values on a graph, so display a gap instead. if (isNaN(val)) {
return null; // "+Inf", "-Inf", "+Inf" will be parsed into NaN by parseFloat(). The
} else { // can't be graphed, so show them as gaps (null).
return parseFloat(value); return null
} }
return val;
}; };
Prometheus.Graph.prototype.transformData = function(json) { Prometheus.Graph.prototype.transformData = function(json) {
self = this; var self = this;
var palette = new Rickshaw.Color.Palette(); var palette = new Rickshaw.Color.Palette();
if (json.type != "matrix") { if (json.type != "matrix") {
self.showError("Result is not of matrix type! Please enter a correct expression."); self.showError("Result is not of matrix type! Please enter a correct expression.");

View file

@ -377,15 +377,17 @@ PromConsole.Graph = function(params) {
}; };
PromConsole.Graph.prototype._parseValue = function(value) { PromConsole.Graph.prototype._parseValue = function(value) {
if (value == "NaN" || value == "Inf" || value == "-Inf") { var val = parseFloat(value);
// Can't display these values on a graph, so display a gap instead. if (isNaN(val)) {
return null; // "+Inf", "-Inf", "+Inf" will be parsed into NaN by parseFloat(). The
} else { // can't be graphed, so show them as gaps (null).
return parseFloat(value); return null
} }
return val;
} }
PromConsole.Graph.prototype._render = function(data) { PromConsole.Graph.prototype._render = function(data) {
var self = this;
var palette = new Rickshaw.Color.Palette(); var palette = new Rickshaw.Color.Palette();
var series = []; var series = [];