Comma-ify pretty printed numbers

This commit is contained in:
Johan Tibell 2012-01-01 15:50:41 -08:00
parent aef1e86114
commit f90d2172fc
2 changed files with 15 additions and 2 deletions

View file

@ -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

View file

@ -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));
});
}