mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-13 06:47:28 -08:00
Merge pull request #2739 from Conorbro/stack-graph-fix
Fixed graph ui max/min logic to accommodate for toggling of stacked graph option
This commit is contained in:
commit
363554f675
File diff suppressed because one or more lines are too long
|
@ -557,24 +557,40 @@ Prometheus.Graph.prototype.updateGraph = function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find and set graph's max/min
|
// Find and set graph's max/min
|
||||||
var min = Infinity;
|
if (self.isStacked() === true) {
|
||||||
var max = -Infinity;
|
// When stacked is toggled
|
||||||
self.data.forEach(function(timeSeries) {
|
var max = 0;
|
||||||
timeSeries.data.forEach(function(dataPoint) {
|
self.data.forEach(function(timeSeries) {
|
||||||
|
var currSeriesMax = 0;
|
||||||
|
timeSeries.data.forEach(function(dataPoint) {
|
||||||
|
if (dataPoint.y > currSeriesMax && dataPoint.y != null) {
|
||||||
|
currSeriesMax = dataPoint.y;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
max += currSeriesMax;
|
||||||
|
});
|
||||||
|
self.rickshawGraph.max = max*1.05;
|
||||||
|
self.rickshawGraph.min = 0;
|
||||||
|
} else {
|
||||||
|
var min = Infinity;
|
||||||
|
var max = -Infinity;
|
||||||
|
self.data.forEach(function(timeSeries) {
|
||||||
|
timeSeries.data.forEach(function(dataPoint) {
|
||||||
if (dataPoint.y < min && dataPoint.y != null) {
|
if (dataPoint.y < min && dataPoint.y != null) {
|
||||||
min = dataPoint.y;
|
min = dataPoint.y;
|
||||||
}
|
}
|
||||||
if (dataPoint.y > max && dataPoint.y != null) {
|
if (dataPoint.y > max && dataPoint.y != null) {
|
||||||
max = dataPoint.y;
|
max = dataPoint.y;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
if (min === max) {
|
||||||
if (min === max) {
|
self.rickshawGraph.max = max + 1;
|
||||||
self.rickshawGraph.max = max + 1;
|
self.rickshawGraph.min = min - 1;
|
||||||
self.rickshawGraph.min = min - 1;
|
} else {
|
||||||
} else {
|
self.rickshawGraph.max = max + (0.1*(Math.abs(max - min)));
|
||||||
self.rickshawGraph.max = max + (0.1*(Math.abs(max - min)));
|
self.rickshawGraph.min = min - (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 xAxis = new Rickshaw.Graph.Axis.Time({ graph: self.rickshawGraph });
|
||||||
|
|
Loading…
Reference in a new issue