From a36e8959faf17d6f0b40a6517c873eb033d6bb10 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Thu, 22 Jun 2017 12:40:36 +0100 Subject: [PATCH] chart dashboard template API extended --- src/app/dashboard/dashboard.component.ts | 30 ++++++++++++++++-------- src/app/providers/api-service.ts | 26 ++++++++++++++++---- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index dbe418c..b6352df 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -8,6 +8,9 @@ import { Router } from '@angular/router'; }) export class DashboardComponent implements OnInit { thisweekcustomerno: any; + lastweekcustomerno: any; + thisweekpoints: any; + lastweekpoints: any; constructor( private http: Http, @@ -18,9 +21,18 @@ export class DashboardComponent implements OnInit { .subscribe( result => { console.log(result); - this.thisweekcustomerno = result; + this.thisweekcustomerno = result.customersthisweek; this.lineChart1Data[0].data = this.thisweekcustomerno.customerno; this.lineChart1Labels = this.thisweekcustomerno.day; + this.lastweekcustomerno = result.customerslastweek; + this.lineChart2Data[0].data = this.lastweekcustomerno.customerno; + this.lineChart2Labels = this.lastweekcustomerno.day; + this.thisweekpoints = result.pointsthisweek; + this.lineChart3Data[0].data = this.thisweekpoints.points; + this.lineChart3Labels = this.thisweekpoints.day; + this.lastweekpoints = result.pointslastweek; + this.barChart1Data[0].data = this.lastweekpoints.points; + this.barChart1Labels = this.lastweekpoints.day; } ) } @@ -114,11 +126,11 @@ export class DashboardComponent implements OnInit { // lineChart2 public lineChart2Data: Array = [ { - data: [1, 18, 9, 17, 34, 22, 11], - label: 'Series A' + data: [], + label: 'Series B' } ]; - public lineChart2Labels: Array = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; + public lineChart2Labels: Array = []; public lineChart2Options: any = { maintainAspectRatio: false, scales: { @@ -137,8 +149,6 @@ export class DashboardComponent implements OnInit { display: false, ticks: { display: false, - min: 1 - 5, - max: 34 + 5, } }], }, @@ -170,11 +180,11 @@ export class DashboardComponent implements OnInit { // lineChart3 public lineChart3Data: Array = [ { - data: [78, 81, 80, 45, 34, 12, 40], + data: [], label: 'Series A' } ]; - public lineChart3Labels: Array = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; + public lineChart3Labels: Array = []; public lineChart3Options: any = { maintainAspectRatio: false, scales: { @@ -212,11 +222,11 @@ export class DashboardComponent implements OnInit { // barChart1 public barChart1Data: Array = [ { - data: [78, 81, 80, 45, 34, 12, 40, 78, 81, 80, 45, 34, 12, 40, 12, 40], + data: [], label: 'Series A' } ]; - public barChart1Labels: Array = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16']; + public barChart1Labels: Array = []; public barChart1Options: any = { maintainAspectRatio: false, scales: { diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index cd1e152..bcd6f19 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -88,10 +88,28 @@ export class ApiService { public graph_data(data) { return Observable.of( - { - day : ['Monday', 'tuesday','wednesday','thursday','friday','saturday','sunday'], - customerno : [1,2,3,4,5,6,7], - } + { + "customersthisweek" : + { + day : ['Monday', 'tuesday','wednesday','thursday','friday','saturday','sunday'], + customerno : [1,2,3,4,5,6,7], + }, + "customerslastweek" : + { + day : ['Monday', 'tuesday','wednesday','thursday','friday','saturday','sunday'], + customerno : [7,6,5,4,3,2,1], + }, + "pointsthisweek" : + { + day : ['Monday', 'tuesday','wednesday','thursday','friday','saturday','sunday'], + points : [1,2,3,4,5,6,7], + }, + "pointslastweek" : + { + day : ['Monday', 'tuesday','wednesday','thursday','friday','saturday','sunday'], + points : [1,2,3,4,5,6,7], + } + } ) } } \ No newline at end of file