Added min/max to graph to accomodate for constant time series (#2612)

Added min/max to graph to accommodate constant time series
This commit is contained in:
Conor Broderick 2017-04-12 14:25:25 +01:00 committed by Brian Brazil
parent 1fb2190eeb
commit ee62807b62
2 changed files with 24 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -556,6 +556,27 @@ Prometheus.Graph.prototype.updateGraph = function() {
min: "auto",
});
// Find and set graph's max/min
var min = Infinity;
var max = -Infinity;
self.data.forEach(function(timeSeries) {
timeSeries.data.forEach(function(dataPoint) {
if (dataPoint.y < min && dataPoint.y != null) {
min = dataPoint.y;
}
if (dataPoint.y > max && dataPoint.y != null) {
max = dataPoint.y;
}
});
});
if (min === max) {
self.rickshawGraph.max = max + 1;
self.rickshawGraph.min = min - 1;
} else {
self.rickshawGraph.max = max + (0.1*(Math.abs(max - min)));
self.rickshawGraph.min = min - (0.1*(Math.abs(max - min)));
}
var xAxis = new Rickshaw.Graph.Axis.Time({ graph: self.rickshawGraph });
var yAxis = new Rickshaw.Graph.Axis.Y({