Merge branch 'release-1.7'

This commit is contained in:
beorn7 2017-09-21 18:27:12 +02:00
commit 16c95ae8e7
2 changed files with 52 additions and 9 deletions

File diff suppressed because one or more lines are too long

View file

@ -621,7 +621,7 @@ Prometheus.Graph.prototype.updateGraph = function() {
var yAxis = new Rickshaw.Graph.Axis.Y({ var yAxis = new Rickshaw.Graph.Axis.Y({
graph: self.rickshawGraph, graph: self.rickshawGraph,
orientation: "left", orientation: "left",
tickFormat: Rickshaw.Fixtures.Number.formatKMBT, tickFormat: this.formatKMBT,
element: self.yAxis[0], element: self.yAxis[0],
}); });
@ -734,6 +734,49 @@ Prometheus.Graph.prototype.remove = function() {
self.handleChange(); self.handleChange();
}; };
Prometheus.Graph.prototype.formatKMBT = function(y) {
var abs_y = Math.abs(y);
if (abs_y >= 1e24) {
return (y / 1e24).toString() + "Y";
} else if (abs_y >= 1e21) {
return (y / 1e21).toString() + "Z";
} else if (abs_y >= 1e18) {
return (y / 1e18).toString() + "E";
} else if (abs_y >= 1e15) {
return (y / 1e15).toString() + "P";
} else if (abs_y >= 1e12) {
return (y / 1e12).toString() + "T";
} else if (abs_y >= 1e9) {
return (y / 1e9).toString() + "G";
} else if (abs_y >= 1e6) {
return (y / 1e6).toString() + "M";
} else if (abs_y >= 1e3) {
return (y / 1e3).toString() + "k";
} else if (abs_y >= 1) {
return y
} else if (abs_y === 0) {
return y
} else if (abs_y <= 1e-24) {
return (y / 1e-24).toString() + "y";
} else if (abs_y <= 1e-21) {
return (y / 1e-21).toString() + "z";
} else if (abs_y <= 1e-18) {
return (y / 1e-18).toString() + "a";
} else if (abs_y <= 1e-15) {
return (y / 1e-15).toString() + "f";
} else if (abs_y <= 1e-12) {
return (y / 1e-12).toString() + "p";
} else if (abs_y <= 1e-9) {
return (y / 1e-9).toString() + "n";
} else if (abs_y <= 1e-6) {
return (y / 1e-6).toString() + "µ";
} else if (abs_y <=1e-3) {
return (y / 1e-3).toString() + "m";
} else if (abs_y <= 1) {
return y
}
}
function escapeHTML(string) { function escapeHTML(string) {
var entityMap = { var entityMap = {
"&": "&amp;", "&": "&amp;",