From df631ad79364476bd1d0cf3f62ad578477844612 Mon Sep 17 00:00:00 2001 From: Finn Date: Fri, 12 Jul 2019 17:12:01 +0100 Subject: [PATCH] various fixes to dashboard stuff --- .../dashboard/dashboard-customer.component.ts | 2 ++ src/app/dashboard/dashboard.component.ts | 20 +++---------------- src/app/dashboard/dashboard.module.ts | 2 ++ .../more-graphs-and-tables.component.ts | 2 +- src/app/panels/bubble-panel.component.ts | 5 ++--- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/app/dashboard/dashboard-customer.component.ts b/src/app/dashboard/dashboard-customer.component.ts index 34dd082..a59e7cb 100644 --- a/src/app/dashboard/dashboard-customer.component.ts +++ b/src/app/dashboard/dashboard-customer.component.ts @@ -2,7 +2,9 @@ import { Directive, Component, OnInit } from '@angular/core'; import { CurrencyPipe } from '@angular/common'; import { ApiService } from '../providers/api-service'; import { Router } from '@angular/router'; +import { ChartOptions, ChartType, ChartDataSets } from 'chart.js'; import { GraphWidget } from '../widgets/graph-widget.component'; +import { Color, Label } from 'ng2-charts'; import { CustBarSnippetComponent } from '../snippets/cust-snippet-bar.component'; import { PiePanel } from '../panels/pie-panel.component'; import { DataType } from '../shared/data-types.enum'; diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index cf7032e..1973efa 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -226,8 +226,8 @@ export class DashboardComponent { 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'}, + {data: this.purchaseEssential, label: 'Essential', stack: '1'}, + {data: this.purchaseNotEssential, label: 'Non-Essential', stack: '1'}, ]; this.showEssentialBarChart = true; }, @@ -257,21 +257,7 @@ export class DashboardComponent { } private setChartDataSector(dataSec: any) { - this.barChartLabelsCategory = Object.keys(dataSec); - let lineChartDataSectorInitial = Object.keys(dataSec).map(key => dataSec[key]); - this.lineChartDataSector = [ - {data: lineChartDataSectorInitial, label: 'Series A'}, - ]; - 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 () { diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index 69a9cc2..54b742f 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -26,6 +26,7 @@ import { GraphWidget } from '../widgets/graph-widget.component'; import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component'; import { CustBarSnippetComponent } from '../snippets/cust-snippet-bar.component'; import { GraphPanel } from '../panels/graph-panel.component'; +import { BubbleChartComponent } from '../panels/bubble-panel.component'; import { PiePanel } from '../panels/pie-panel.component'; import { OrgPiePanel } from '../panels/org-pie-panel.component'; @@ -82,6 +83,7 @@ import { environment } from '../../environments/environment'; GraphPanel, PiePanel, OrgPiePanel, + BubbleChartComponent, ], providers: [ CurrencyPipe, diff --git a/src/app/dashboard/more-graphs-and-tables.component.ts b/src/app/dashboard/more-graphs-and-tables.component.ts index 65b65bf..533b1d0 100644 --- a/src/app/dashboard/more-graphs-and-tables.component.ts +++ b/src/app/dashboard/more-graphs-and-tables.component.ts @@ -5,7 +5,7 @@ import { Color } from 'ng2-charts'; import { CurrencyPipe } from '@angular/common'; import { DataType } from '../shared/data-types.enum'; import * as moment from 'moment'; -import { BubbleChartComponent } from '../panels/bubble-panel'; +import { BubbleChartComponent } from '../panels/bubble-panel.component'; import { AgmCoreModule } from '@agm/core'; import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal'; import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; diff --git a/src/app/panels/bubble-panel.component.ts b/src/app/panels/bubble-panel.component.ts index d5edbdf..e57a646 100644 --- a/src/app/panels/bubble-panel.component.ts +++ b/src/app/panels/bubble-panel.component.ts @@ -4,8 +4,7 @@ import { Color } from 'ng2-charts'; @Component({ selector: 'app-bubble-chart', - templateUrl: './bubble-chart.component.html', - styleUrls: ['./bubble-chart.component.scss'] + templateUrl: './bubble-panel.component.html', }) export class BubbleChartComponent implements OnInit { public bubbleChartOptions: ChartOptions = { @@ -95,4 +94,4 @@ export class BubbleChartComponent implements OnInit { const data = Array.apply(null, { length: numberOfPoints }).map(r => this.randomPoint(30)); this.bubbleChartData[0].data = data; } -} \ No newline at end of file +}