fixed bar chart

This commit is contained in:
piratefinn 2018-04-11 19:19:34 +01:00
parent 96b4e0f382
commit 823a1d398f

View file

@ -58,7 +58,7 @@ export class PiePanel implements OnInit {
public barChartTypeCategory:string = 'bar'; public barChartTypeCategory:string = 'bar';
public barChartLegendCategory:boolean = false; public barChartLegendCategory:boolean = false;
public barChartDataCategory:any[]=[ public barChartDataCategory:any[]=[
{data: 0, label: 'Series A'}, {data: [], label: 'Series A'},
]; ];
public barChartLabelsCategory:string[] = []; public barChartLabelsCategory:string[] = [];
@ -99,13 +99,16 @@ export class PiePanel implements OnInit {
console.log(dataLocal, dataCat); console.log(dataLocal, dataCat);
this.doughnutChartDataLocal = Object.keys(dataLocal).map(key => dataLocal[key]); this.doughnutChartDataLocal = Object.keys(dataLocal).map(key => dataLocal[key]);
this.barChartLabelsCategory = Object.keys(dataCat); 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;}); this.doughnutChartDataCategory = this.weekList1.map(function(a) {return a.value;});
// setTimeout is currently a workaround for ng2-charts labels // setTimeout is currently a workaround for ng2-charts labels
setTimeout(() => this.doughnutChartLabelsLocal = Object.keys(dataLocal), 0); setTimeout(() => this.doughnutChartLabelsLocal = Object.keys(dataLocal), 0);
setTimeout(() => this.doughnutChartLabelsCategory = this.weekList1.map(function(a) {return a.category;}), 0); setTimeout(() => this.doughnutChartLabelsCategory = this.weekList1.map(function(a) {return a.category;}), 0);
console.log(this.barChartDataCategory); console.log(this.barChartDataCategory);
console.log(this.barChartLabelsCategory); console.log(barChartDataCategoryInitial);
this.showCategoryBarChart = true; this.showCategoryBarChart = true;
} }