Browse Source

Merge branch 'release-1.7'

pull/3205/head
beorn7 7 years ago
parent
commit
16c95ae8e7
  1. 16
      web/ui/bindata.go
  2. 45
      web/ui/static/js/graph.js

16
web/ui/bindata.go

File diff suppressed because one or more lines are too long

45
web/ui/static/js/graph.js

@ -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;",

Loading…
Cancel
Save