From 823a1d398fb71f5c669136f699a1b76251f1498f Mon Sep 17 00:00:00 2001 From: piratefinn Date: Wed, 11 Apr 2018 19:19:34 +0100 Subject: [PATCH] fixed bar chart --- src/app/panels/pie-panel.component.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/panels/pie-panel.component.ts b/src/app/panels/pie-panel.component.ts index f11407a..2c86499 100644 --- a/src/app/panels/pie-panel.component.ts +++ b/src/app/panels/pie-panel.component.ts @@ -58,7 +58,7 @@ export class PiePanel implements OnInit { public barChartTypeCategory:string = 'bar'; public barChartLegendCategory:boolean = false; public barChartDataCategory:any[]=[ - {data: 0, label: 'Series A'}, + {data: [], label: 'Series A'}, ]; public barChartLabelsCategory:string[] = []; @@ -99,13 +99,16 @@ export class PiePanel implements OnInit { console.log(dataLocal, dataCat); this.doughnutChartDataLocal = Object.keys(dataLocal).map(key => dataLocal[key]); this.barChartLabelsCategory = Object.keys(dataCat); - this.barChartDataCategory = Object.keys(dataCat).map(key => dataCat[key]); + let barChartDataCategoryInitial = Object.keys(dataCat).map(key => dataCat[key]); + this.barChartDataCategory = [ + {data: barChartDataCategoryInitial, label: 'Series A'}, + ]; this.doughnutChartDataCategory = this.weekList1.map(function(a) {return a.value;}); // setTimeout is currently a workaround for ng2-charts labels setTimeout(() => this.doughnutChartLabelsLocal = Object.keys(dataLocal), 0); setTimeout(() => this.doughnutChartLabelsCategory = this.weekList1.map(function(a) {return a.category;}), 0); console.log(this.barChartDataCategory); - console.log(this.barChartLabelsCategory); + console.log(barChartDataCategoryInitial); this.showCategoryBarChart = true; }