Comma-ify pretty printed numbers
This commit is contained in:
parent
aef1e86114
commit
f90d2172fc
2 changed files with 15 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
## 0.3.0.0 (2011-12-31)
|
||||
## 0.3.0.0 (2012-01-01)
|
||||
|
||||
* Add gauges and change counters to always be monotonically increasing
|
||||
|
||||
|
|
|
@ -2,6 +2,19 @@ $(document).ready(function () {
|
|||
"use strict";
|
||||
|
||||
// Number formatters
|
||||
function commaify(n)
|
||||
{
|
||||
var nStr = n.toString();
|
||||
var x = nStr.split('.');
|
||||
var x1 = x[0];
|
||||
var x2 = x.length > 1 ? '.' + x[1] : '';
|
||||
var rgx = /(\d+)(\d{3})/;
|
||||
while (rgx.test(x1)) {
|
||||
x1 = x1.replace(rgx, '$1' + ',' + '$2');
|
||||
}
|
||||
return x1 + x2;
|
||||
}
|
||||
|
||||
function formatSuffix(val, opt_prec) {
|
||||
if (val === null) {
|
||||
return "N/A";
|
||||
|
@ -223,7 +236,7 @@ $(document).ready(function () {
|
|||
});
|
||||
}
|
||||
if (!paused)
|
||||
elem.text(value);
|
||||
elem.text(commaify(value));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue