From ff9079e331b36c67f50266547aada1c3431bc302 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Mon, 16 Apr 2018 15:41:45 +0100 Subject: [PATCH] Amended for possible undefined error --- .../dashboard/dashboard-customer.component.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/dashboard/dashboard-customer.component.ts b/src/app/dashboard/dashboard-customer.component.ts index 0d17e88..cebb1f8 100644 --- a/src/app/dashboard/dashboard-customer.component.ts +++ b/src/app/dashboard/dashboard-customer.component.ts @@ -240,14 +240,16 @@ export class DashboardCustomerComponent implements OnInit { this.barChartDataCategory = [ {data: barChartDataCategoryInitial, label: 'Series A'}, ]; - let doughnutChartDataCategoryInitial = this.weekList1.map(function(a) {return a.value;}); - this.doughnutChartDataCategory = [ - {data: doughnutChartDataCategoryInitial, label: 'Series A'}, - ]; - // setTimeout is currently a workaround for ng2-charts labels - setTimeout(() => this.doughnutChartLabelsCategory = this.weekList1.map(function(a) {return a.category;}), 0); - this.showCategoryDoughnutChart = true; this.showCategoryBarChart = true; + if (this.weekList1) { + let doughnutChartDataCategoryInitial = this.weekList1.map(function(a) {return a.value;}); + this.doughnutChartDataCategory = [ + {data: doughnutChartDataCategoryInitial, label: 'Series A'}, + ]; + // setTimeout is currently a workaround for ng2-charts labels + setTimeout(() => this.doughnutChartLabelsCategory = this.weekList1.map(function(a) {return a.category;}), 0); + this.showCategoryDoughnutChart = true; + } } private setDate () {