-
-
-
Global Puchases by Category
-
-
-
-
-
- -
-
-
-
{{ category.category || 'N/A' }}
-
-
-
Bought
-
{{ category.value || 'N/A' }}
+
+
+
+
+
+
Global Puchases by Category
+
+
+
+
+
+ -
+
+
+
{{ category.category || 'N/A' }}
+
+
+
Bought
+
{{ category.value || 'N/A' }}
+
+
+ - totalCategoryLimit && disableCategoryButton == false" class="divider text-center">
+
+
+
-
-
- totalCategoryLimit && disableCategoryButton == false" class="divider text-center">
-
-
-
+
+
-
-
-
-
+
diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts
index e12dbfa..0756ab3 100644
--- a/src/app/dashboard/dashboard.component.ts
+++ b/src/app/dashboard/dashboard.component.ts
@@ -114,13 +114,13 @@ export class DashboardComponent {
public purchaseNotEssential: number;
public purchaseEssential: number;
- public showEssentialBarChart = false;
+ public showEssentialBarChart:boolean = false;
public showCategoryBarChart = false;
public showCategoryDoughnutChart = false;
- public barChartDataEssential:any[]=[
- {data: 0, label: 'Essential', stack: '1'},
- {data: 0, label: 'Non-Essential', stack: '1'},
+ public barChartDataEssential: ChartDataSets[] = [
+ {data: [0], label: 'Essential', stack: '1'},
+ {data: [0], label: 'Non-Essential', stack: '1'},
];
public barChartLabelsEssential:string[] = ['All Purchases'];
public barChartOptionsEssential:any = {
@@ -265,17 +265,11 @@ export class DashboardComponent {
this.setWeekPurchaseList(result.weeks);
this.setWeekData(result);
this.setChartDataCat(result.data.cat_total);
+ this.setChartDataEssential(result.data.essentials);
this.totalCategoryList = result.data.cat_list;
if (this.totalCategoryList) {
this.showTotalCategoryList = true;
}
- this.purchaseEssential = result.data.essentials.purchase_no_essential_total;
- this.purchaseNotEssential = result.data.essentials.purchase_no_total - this.purchaseEssential;
- this.barChartDataEssential = [
- {data: this.purchaseEssential, label: 'Essential', stack: '1'},
- {data: this.purchaseNotEssential, label: 'Non-Essential', stack: '1'},
- ];
- this.showEssentialBarChart = true;
},
error => {
console.log('Retrieval Error');
@@ -284,6 +278,17 @@ export class DashboardComponent {
);
}
+ private setChartDataEssential (dataEs: any) {
+ this.purchaseEssential = dataEs.purchase_no_essential_total;
+ this.purchaseNotEssential = dataEs.purchase_no_total - this.purchaseEssential;
+ this.barChartDataEssential = [
+ {data: [this.purchaseEssential], label: 'Essential', stack: '1'},
+ {data: [this.purchaseNotEssential], label: 'Non-Essential', stack: '1'},
+ ];
+ this.showEssentialBarChart = true;
+ console.log(this.barChartDataEssential);
+ }
+
private setChartDataCat(dataCat: any) {
this.barChartLabelsCategory = Object.keys(dataCat);
let barChartDataCategoryInitial = Object.keys(dataCat).map(key => dataCat[key]);