From cf27a27a6a2088ccfec136548010d09e3425a955 Mon Sep 17 00:00:00 2001 From: borja123456 Date: Wed, 15 Apr 2020 22:53:29 +0200 Subject: [PATCH] Statistics bug fixed --- .../statistics/statistics.component.html | 2 +- .../statistics/statistics.component.ts | 16 +++++++++------- .../services/statistics/statistics.service.ts | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/AngularAnimalShelter/src/app/components/statistics/statistics.component.html b/AngularAnimalShelter/src/app/components/statistics/statistics.component.html index 3c17e7b..02a55ba 100644 --- a/AngularAnimalShelter/src/app/components/statistics/statistics.component.html +++ b/AngularAnimalShelter/src/app/components/statistics/statistics.component.html @@ -21,7 +21,7 @@

Statistics

Adoptions in last six Months

diff --git a/AngularAnimalShelter/src/app/components/statistics/statistics.component.ts b/AngularAnimalShelter/src/app/components/statistics/statistics.component.ts index 5bf2c5a..4b3295d 100644 --- a/AngularAnimalShelter/src/app/components/statistics/statistics.component.ts +++ b/AngularAnimalShelter/src/app/components/statistics/statistics.component.ts @@ -3,7 +3,7 @@ import { Component, OnInit } from '@angular/core'; import { StatisticsService } from '../../services/statistics/statistics.service'; import { ChartOptions, ChartType, ChartDataSets } from 'chart.js'; -import { Label } from 'ng2-charts'; + @Component({ @@ -11,10 +11,12 @@ import { Label } from 'ng2-charts'; templateUrl: './statistics.component.html', styleUrls: ['./statistics.component.css'] }) + + export class StatisticsComponent { actualMonth: any = new Date().getMonth()+1; meses = ["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]; - adoptions: any=[]; + adoptions: Array=[]; constructor (private statistics: StatisticsService){} ngOnInit(): void { let itera= this.actualMonth; @@ -29,22 +31,22 @@ export class StatisticsComponent { itera=11; } this.barChartLabels.push(this.meses[itera]); - salida++; } + console.log(this.adoptions); + } public barChartLabels:String []=[]; public barChartOptions: ChartOptions = { responsive: true, } + public barCharData : ChartDataSets[] =[ + {data: this.adoptions, label: "Animals Adopted"} + ]; public barChartType: ChartType = 'bar'; } - - - - diff --git a/AngularAnimalShelter/src/app/services/statistics/statistics.service.ts b/AngularAnimalShelter/src/app/services/statistics/statistics.service.ts index 317942a..984b083 100644 --- a/AngularAnimalShelter/src/app/services/statistics/statistics.service.ts +++ b/AngularAnimalShelter/src/app/services/statistics/statistics.service.ts @@ -10,7 +10,7 @@ export class StatisticsService { constructor(private _http: HttpClient) {} adoptionsMonth(month: any){ - return this._http.get(`${this.BASE_URL}/${month}`); + return this._http.get(`${this.BASE_URL}/${month}`); } private handleError(error: any) {