From 182679e9acaeecbdd3f721e260cda1bfad520493 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Thu, 25 Jan 2018 11:18:31 +0000 Subject: [PATCH] Changed percentages on budget view screen --- .../dashboard/category-month.component.html | 24 +++++++++---------- src/app/dashboard/category-month.component.ts | 16 ++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/app/dashboard/category-month.component.html b/src/app/dashboard/category-month.component.html index 5b5434d..0a7c91f 100644 --- a/src/app/dashboard/category-month.component.html +++ b/src/app/dashboard/category-month.component.html @@ -5,7 +5,7 @@
-

Purchases this week

+

Purchases Last Week

@@ -13,11 +13,11 @@
  • {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (categoryEntry.value || 0 ) / weekListValueMax1 | percent:'1.0-0' }}) + ({{ (categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }})
    + [style.width]="(categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100">
  • @@ -36,7 +36,7 @@
    -

    Purchases last week

    +

    Purchases 1 Week Ago

    @@ -44,11 +44,11 @@
  • {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (categoryEntry.value || 0 ) / weekListValueMax2 | percent:'1.0-0' }}) + ({{ (categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }})
    + [style.width]="(categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100">
  • @@ -67,7 +67,7 @@
    -

    Purchases 2 weeks ago

    +

    Purchases 2 Weeks Ago

    @@ -75,11 +75,11 @@
  • {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (categoryEntry.value || 0 ) / weekListValueMax3 | percent:'1.0-0' }}) + ({{ (categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }})
    + [style.width]="(categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100">
  • @@ -98,7 +98,7 @@
    -

    Purchases 3 weeks ago

    +

    Purchases 3 Weeks Ago

    @@ -106,11 +106,11 @@
  • {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (categoryEntry.value || 0 ) / weekListValueMax4 | percent:'1.0-0' }}) + ({{ (categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }})
    + [style.width]="(categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100">
  • diff --git a/src/app/dashboard/category-month.component.ts b/src/app/dashboard/category-month.component.ts index 6569a26..e8353cf 100644 --- a/src/app/dashboard/category-month.component.ts +++ b/src/app/dashboard/category-month.component.ts @@ -22,10 +22,10 @@ export class CategoryMonthComponent implements OnInit { weekList2 = []; weekList3 = []; weekList4 = []; - weekListValueMax1: number = 0; - weekListValueMax2: number = 0; - weekListValueMax3: number = 0; - weekListValueMax4: number = 0; + weekListValueSum1: number = 0; + weekListValueSum2: number = 0; + weekListValueSum3: number = 0; + weekListValueSum4: number = 0; categoryList: number[] = []; dayList: any[] = []; @@ -97,16 +97,16 @@ export class CategoryMonthComponent implements OnInit { data3: any, data4: any) { if (data1) { - this.weekListValueMax1 = Math.max.apply(Math,data1.map(function(o){return o.value;})); + this.weekListValueSum1 = data1.reduce(function (s, a) {return s + a.value;}, 0); } if (data2) { - this.weekListValueMax2 = Math.max.apply(Math,data2.map(function(o){return o.value;})); + this.weekListValueSum2 = data2.reduce(function (s, a) {return s + a.value;}, 0); } if (data3) { - this.weekListValueMax3 = Math.max.apply(Math,data3.map(function(o){return o.value;})); + this.weekListValueSum3 = data3.reduce(function (s, a) {return s + a.value;}, 0); } if (data4) { - this.weekListValueMax4 = Math.max.apply(Math,data4.map(function(o){return o.value;})); + this.weekListValueSum4 = data4.reduce(function (s, a) {return s + a.value;}, 0); } }