From 7e7bb4ccf3eab74befcc74974d6003e9807d7c99 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Thu, 14 Dec 2017 20:14:47 +0000 Subject: [PATCH] percent per week data viewing done --- .../dashboard-customer.component.html | 86 ++++++++++++++----- .../dashboard/dashboard-customer.component.ts | 46 ++++++++-- src/app/panels/pie-panel.component.ts | 2 - 3 files changed, 104 insertions(+), 30 deletions(-) diff --git a/src/app/dashboard/dashboard-customer.component.html b/src/app/dashboard/dashboard-customer.component.html index 3b9f793..1278c05 100644 --- a/src/app/dashboard/dashboard-customer.component.html +++ b/src/app/dashboard/dashboard-customer.component.html @@ -10,12 +10,11 @@ -
-
+
-
+
@@ -27,37 +26,78 @@
  • This Week - 191,235 (56%) + {{ (weekPurchaseList.week_0 || 0 ) }} ({{ (weekPurchaseList.week_0 || 0 ) / maxPurchase | percent:'1.0-0' }})
    -
    -
    +
    +
  • Last Week - 51,223 (15%) + {{ weekPurchaseList.week_1 || 0 }} ({{ (weekPurchaseList.week_1 || 0 ) / maxPurchase | percent:'1.0-0' }})
    -
    -
    +
    +
  • 2 Weeks Ago - 37,564 (11%) + {{ weekPurchaseList.week_2 || 0 }} ({{ (weekPurchaseList.week_2 || 0 ) / maxPurchase | percent:'1.0-0' }})
    -
    -
    +
    +
  • 3 Weeks Ago - 27,319 (8%) + {{ weekPurchaseList.week_3 || 0 }} ({{ (weekPurchaseList.week_3 || 0 ) / maxPurchase | percent:'1.0-0' }})
    -
    -
    +
    +
    +
    +
    +
  • +
  • + 4 Weeks Ago + {{ weekPurchaseList.week_4 || 0 }} ({{ (weekPurchaseList.week_4 || 0 ) / maxPurchase | percent:'1.0-0' }}) +
    +
    +
    +
    +
    +
  • +
  • + 5 Weeks Ago + {{ weekPurchaseList.week_5 || 0 }} ({{ (weekPurchaseList.week_5 || 0 ) / maxPurchase | percent:'1.0-0' }}) +
    +
    +
    +
    +
    +
  • +
  • + 6 Weeks Ago + {{ weekPurchaseList.week_6 || 0 }} ({{ (weekPurchaseList.week_6 || 0 ) / maxPurchase | percent:'1.0-0' }}) +
    +
    +
  • @@ -66,7 +106,7 @@
-
+
@@ -83,7 +123,7 @@ Lorem ipsum dolor sit amet
-
Bought this week
+
Bought from Sector
1.924
@@ -94,7 +134,7 @@ Lorem ipsum dolor sit amet
-
Bought this week
+
Bought from Sector
1.224
@@ -105,7 +145,7 @@ Lorem ipsum dolor sit amet
-
Bought this week
+
Bought from Sector
1.163
@@ -116,7 +156,7 @@ Lorem ipsum dolor sit amet
-
Bought this week
+
Bought from Sector
928
@@ -127,7 +167,7 @@ Lorem ipsum dolor sit amet
-
Bought this week
+
Bought from Sector
893
@@ -138,7 +178,7 @@ Lorem ipsum dolor sit amet
-
Bought this week
+
Bought from Sector
121.924
@@ -149,7 +189,7 @@ Lorem ipsum dolor sit amet
-
Bought this week
+
Bought from Sector
12.125
diff --git a/src/app/dashboard/dashboard-customer.component.ts b/src/app/dashboard/dashboard-customer.component.ts index 87b5419..f404496 100644 --- a/src/app/dashboard/dashboard-customer.component.ts +++ b/src/app/dashboard/dashboard-customer.component.ts @@ -19,12 +19,19 @@ export class DashboardCustomerComponent implements OnInit { myRank: any; username: any; - // PolarArea - public polarAreaChartLabels: string[] = ['Local', 'Not Local']; - public polarAreaChartData: number[] = [400, 100]; - public polarAreaLegend = true; - public polarAreaChartType = 'polarArea'; + weekPurchaseList = { + week_0: 0, + week_1: 0, + week_2: 0, + week_3: 0, + week_4: 0, + week_5: 0, + week_6: 0, + }; + sectorList: any; + + // Graph widgets public widgetList = [ { type: 'graph', @@ -57,6 +64,35 @@ export class DashboardCustomerComponent implements OnInit { constructor( private api: ApiService, ) { + this.api.basicStats().subscribe( + result => { + this.setWeekPurchaseList(result.data); + + }, + error => { + console.log('Retrieval Error'); + console.log( error._body ); + } + ); + } + + public setWeekPurchaseList (data: any) { + this.weekPurchaseList = { + week_0: data.purchases[0], + week_1: data.purchases[1], + week_2: data.purchases[2], + week_3: data.purchases[3], + week_4: data.purchases[4], + week_5: data.purchases[5], + week_6: data.purchases[6], + }; + //this.maxPurchase = Math.max(...this.weekPurchaseList); + this.maxPurchase = Object.values(this.weekPurchaseList).reduce((a,b) => { + if (! a) { a = 0 } + if (! b) { b = 0 } + return Math.max(a,b); + }); + console.log(this.maxPurchase); } ngOnInit(): void { diff --git a/src/app/panels/pie-panel.component.ts b/src/app/panels/pie-panel.component.ts index e102b33..3e8d2ac 100644 --- a/src/app/panels/pie-panel.component.ts +++ b/src/app/panels/pie-panel.component.ts @@ -30,10 +30,8 @@ export class PiePanel implements OnInit { private setData(data: any) { this.doughnutChartData = Object.values(data); - console.log(this.chartData); // setTimeout is currently a workaround for ng2-charts labels setTimeout(() => this.doughnutChartLabels = Object.keys(data), 0); - console.log(this.chartLabels); } // convert Hex to RGBA