Limit decimal precision to 15 places.
This prevents numerical operations from showing ugly floating point
representation errors like 29994.9999999997; just show 29995 instead.
diff --git a/render.js b/render.js
index 0adf8ef..8e10ce7 100644
--- a/render.js
+++ b/render.js
@@ -937,6 +937,20 @@
}
+ function limitDecimalPrecision(grid) {
+ for (var rowi in grid.data) {
+ var row = grid.data[rowi];
+ for (var coli in row) {
+ var cell = row[coli];
+ if (cell === +cell) {
+ row[coli] = parseFloat(cell.toPrecision(15))
+ }
+ }
+ }
+ return grid;
+ }
+
+
function fillNullsWithZero(grid) {
for (var rowi in grid.data) {
var row = grid.data[rowi];
@@ -1105,6 +1119,7 @@
// Some charts react badly to missing values, so fill them in.
grid = fillNullsWithZero(grid);
}
+ grid = limitDecimalPrecision(grid);
var el = document.getElementById('vizchart');
if (args.get('title')) {
options.title = args.get('title');