Commit ce5f45eadeb33f9b29b702e3e4ae4a1aadaade36
1 parent
90c7b0e4
Exists in
master
and in
4 other branches
Fix data bug
used to forget first category value
Showing
1 changed file
with
2 additions
and
1 deletions
Show diff stats
app/main/static/js/charges.js
@@ -298,13 +298,14 @@ function build_chart(div_selector, data_url, entity_name, category_type) { | @@ -298,13 +298,14 @@ function build_chart(div_selector, data_url, entity_name, category_type) { | ||
298 | // 1- Get the charge sum for each category over periods | 298 | // 1- Get the charge sum for each category over periods |
299 | // That will leave '0' to categories with no charge at all | 299 | // That will leave '0' to categories with no charge at all |
300 | // TODO: to be done with Object.keys, Object.values and d3 filtering methods | 300 | // TODO: to be done with Object.keys, Object.values and d3 filtering methods |
301 | + // | ||
301 | var categories_total_charge = {} | 302 | var categories_total_charge = {} |
302 | data.forEach(function (d) { | 303 | data.forEach(function (d) { |
303 | Object.keys(d).forEach(function (k) { | 304 | Object.keys(d).forEach(function (k) { |
304 | if (categories_total_charge.hasOwnProperty(k)) { | 305 | if (categories_total_charge.hasOwnProperty(k)) { |
305 | categories_total_charge[k] += +d[k] | 306 | categories_total_charge[k] += +d[k] |
306 | } else { | 307 | } else { |
307 | - categories_total_charge[k] = 0 | 308 | + categories_total_charge[k] = d[k] |
308 | } | 309 | } |
309 | } | 310 | } |
310 | ) | 311 | ) |