diff --git a/app/main/static/js/charges.js b/app/main/static/js/charges.js index d0fb228..9df030a 100644 --- a/app/main/static/js/charges.js +++ b/app/main/static/js/charges.js @@ -1,3 +1,7 @@ +function roundToTwo(num) { + return +(Math.round(num + "e+2") + "e-2"); +} + function build_chart(div_selector, data_url, entity_name, category_type) { const main_elt = document.getElementById("main") @@ -247,7 +251,7 @@ function build_chart(div_selector, data_url, entity_name, category_type) { var period_values = Object.values(d).slice(1) var row = {} row['period'] = d.period - row['total'] = d3.sum(period_values) + row['total'] = roundToTwo(d3.sum(period_values)) periods_total_charge.push(row) }); @@ -310,6 +314,7 @@ function build_chart(div_selector, data_url, entity_name, category_type) { } else { categories_total_charge[k] = +d[k] } + categories_total_charge[k] = roundToTwo(categories_total_charge[k]) } ) }) -- libgit2 0.21.2