From d7de013954e322057b222e96c0a181f492078586 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Wed, 5 Jul 2017 23:19:24 +0200 Subject: [PATCH] Fix category loading. --- src/operations/category-chart.component.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/operations/category-chart.component.js b/src/operations/category-chart.component.js index 65b2062..06f9f1d 100644 --- a/src/operations/category-chart.component.js +++ b/src/operations/category-chart.component.js @@ -53,17 +53,22 @@ var categoryChartModule = angular.module('categoryChartModule', [ expensesColor = 'orange'; angular.forEach(results, function(result) { - var revenuesName = 'revenues-' + result.category; - revenues.push([revenuesName, result.revenues]); - names[revenuesName] = result.category; - colors[revenuesName] = revenuesColor; + if(result.revenues > 0) { + var revenuesName = 'revenues-' + result.category; - var expensesName = 'expenses-' + result.category; + revenues.push([revenuesName, result.revenues]); + names[revenuesName] = result.category; + colors[revenuesName] = revenuesColor; + } - expenses.splice(0, 0, [expensesName, -result.expenses]); - names[expensesName] = result.category; - colors[expensesName] = expensesColor; + if(result.expenses < 0) { + var expensesName = 'expenses-' + result.category; + + expenses.splice(0, 0, [expensesName, -result.expenses]); + names[expensesName] = result.category; + colors[expensesName] = expensesColor; + } }); vm.chart.unload();