chart dashboard template API extended

This commit is contained in:
piratefinn 2017-06-22 12:40:36 +01:00
parent ee253f263f
commit a36e8959fa
2 changed files with 42 additions and 14 deletions

View file

@ -8,6 +8,9 @@ import { Router } from '@angular/router';
}) })
export class DashboardComponent implements OnInit { export class DashboardComponent implements OnInit {
thisweekcustomerno: any; thisweekcustomerno: any;
lastweekcustomerno: any;
thisweekpoints: any;
lastweekpoints: any;
constructor( constructor(
private http: Http, private http: Http,
@ -18,9 +21,18 @@ export class DashboardComponent implements OnInit {
.subscribe( .subscribe(
result => { result => {
console.log(result); console.log(result);
this.thisweekcustomerno = result; this.thisweekcustomerno = result.customersthisweek;
this.lineChart1Data[0].data = this.thisweekcustomerno.customerno; this.lineChart1Data[0].data = this.thisweekcustomerno.customerno;
this.lineChart1Labels = this.thisweekcustomerno.day; 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 // lineChart2
public lineChart2Data: Array<any> = [ public lineChart2Data: Array<any> = [
{ {
data: [1, 18, 9, 17, 34, 22, 11], data: [],
label: 'Series A' label: 'Series B'
} }
]; ];
public lineChart2Labels: Array<any> = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; public lineChart2Labels: Array<any> = [];
public lineChart2Options: any = { public lineChart2Options: any = {
maintainAspectRatio: false, maintainAspectRatio: false,
scales: { scales: {
@ -137,8 +149,6 @@ export class DashboardComponent implements OnInit {
display: false, display: false,
ticks: { ticks: {
display: false, display: false,
min: 1 - 5,
max: 34 + 5,
} }
}], }],
}, },
@ -170,11 +180,11 @@ export class DashboardComponent implements OnInit {
// lineChart3 // lineChart3
public lineChart3Data: Array<any> = [ public lineChart3Data: Array<any> = [
{ {
data: [78, 81, 80, 45, 34, 12, 40], data: [],
label: 'Series A' label: 'Series A'
} }
]; ];
public lineChart3Labels: Array<any> = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; public lineChart3Labels: Array<any> = [];
public lineChart3Options: any = { public lineChart3Options: any = {
maintainAspectRatio: false, maintainAspectRatio: false,
scales: { scales: {
@ -212,11 +222,11 @@ export class DashboardComponent implements OnInit {
// barChart1 // barChart1
public barChart1Data: Array<any> = [ public barChart1Data: Array<any> = [
{ {
data: [78, 81, 80, 45, 34, 12, 40, 78, 81, 80, 45, 34, 12, 40, 12, 40], data: [],
label: 'Series A' label: 'Series A'
} }
]; ];
public barChart1Labels: Array<any> = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16']; public barChart1Labels: Array<any> = [];
public barChart1Options: any = { public barChart1Options: any = {
maintainAspectRatio: false, maintainAspectRatio: false,
scales: { scales: {

View file

@ -88,9 +88,27 @@ export class ApiService {
public graph_data(data) { public graph_data(data) {
return Observable.of( return Observable.of(
{
"customersthisweek" :
{ {
day : ['Monday', 'tuesday','wednesday','thursday','friday','saturday','sunday'], day : ['Monday', 'tuesday','wednesday','thursday','friday','saturday','sunday'],
customerno : [1,2,3,4,5,6,7], 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],
}
} }
) )
} }