various fixes to dashboard stuff

This commit is contained in:
Finn 2019-07-12 17:12:01 +01:00
parent c0570cddf8
commit 05506ed1b6
5 changed files with 10 additions and 21 deletions

View file

@ -2,7 +2,9 @@ import { Directive, Component, OnInit } from '@angular/core';
import { CurrencyPipe } from '@angular/common'; import { CurrencyPipe } from '@angular/common';
import { ApiService } from '../providers/api-service'; import { ApiService } from '../providers/api-service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { ChartOptions, ChartType, ChartDataSets } from 'chart.js';
import { GraphWidget } from '../widgets/graph-widget.component'; import { GraphWidget } from '../widgets/graph-widget.component';
import { Color, Label } from 'ng2-charts';
import { CustBarSnippetComponent } from '../snippets/cust-snippet-bar.component'; import { CustBarSnippetComponent } from '../snippets/cust-snippet-bar.component';
import { PiePanel } from '../panels/pie-panel.component'; import { PiePanel } from '../panels/pie-panel.component';
import { DataType } from '../shared/data-types.enum'; import { DataType } from '../shared/data-types.enum';

View file

@ -226,8 +226,8 @@ export class DashboardComponent {
this.purchaseEssential = result.data.essentials.purchase_no_essential_total; this.purchaseEssential = result.data.essentials.purchase_no_essential_total;
this.purchaseNotEssential = result.data.essentials.purchase_no_total - this.purchaseEssential; this.purchaseNotEssential = result.data.essentials.purchase_no_total - this.purchaseEssential;
this.barChartDataEssential = [ this.barChartDataEssential = [
{data: [this.purchaseEssential], label: 'Essential', stack: '1'}, {data: this.purchaseEssential, label: 'Essential', stack: '1'},
{data: [this.purchaseNotEssential], label: 'Non-Essential', stack: '1'}, {data: this.purchaseNotEssential, label: 'Non-Essential', stack: '1'},
]; ];
this.showEssentialBarChart = true; this.showEssentialBarChart = true;
}, },
@ -257,21 +257,7 @@ export class DashboardComponent {
} }
private setChartDataSector(dataSec: any) { 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 () { private setDate () {

View file

@ -26,6 +26,7 @@ import { GraphWidget } from '../widgets/graph-widget.component';
import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component'; import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component';
import { CustBarSnippetComponent } from '../snippets/cust-snippet-bar.component'; import { CustBarSnippetComponent } from '../snippets/cust-snippet-bar.component';
import { GraphPanel } from '../panels/graph-panel.component'; import { GraphPanel } from '../panels/graph-panel.component';
import { BubbleChartComponent } from '../panels/bubble-panel.component';
import { PiePanel } from '../panels/pie-panel.component'; import { PiePanel } from '../panels/pie-panel.component';
import { OrgPiePanel } from '../panels/org-pie-panel.component'; import { OrgPiePanel } from '../panels/org-pie-panel.component';
@ -82,6 +83,7 @@ import { environment } from '../../environments/environment';
GraphPanel, GraphPanel,
PiePanel, PiePanel,
OrgPiePanel, OrgPiePanel,
BubbleChartComponent,
], ],
providers: [ providers: [
CurrencyPipe, CurrencyPipe,

View file

@ -5,7 +5,7 @@ import { Color } from 'ng2-charts';
import { CurrencyPipe } from '@angular/common'; import { CurrencyPipe } from '@angular/common';
import { DataType } from '../shared/data-types.enum'; import { DataType } from '../shared/data-types.enum';
import * as moment from 'moment'; import * as moment from 'moment';
import { BubbleChartComponent } from '../panels/bubble-panel'; import { BubbleChartComponent } from '../panels/bubble-panel.component';
import { AgmCoreModule } from '@agm/core'; import { AgmCoreModule } from '@agm/core';
import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal'; import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';

View file

@ -4,8 +4,7 @@ import { Color } from 'ng2-charts';
@Component({ @Component({
selector: 'app-bubble-chart', selector: 'app-bubble-chart',
templateUrl: './bubble-chart.component.html', templateUrl: './bubble-panel.component.html',
styleUrls: ['./bubble-chart.component.scss']
}) })
export class BubbleChartComponent implements OnInit { export class BubbleChartComponent implements OnInit {
public bubbleChartOptions: ChartOptions = { public bubbleChartOptions: ChartOptions = {
@ -95,4 +94,4 @@ export class BubbleChartComponent implements OnInit {
const data = Array.apply(null, { length: numberOfPoints }).map(r => this.randomPoint(30)); const data = Array.apply(null, { length: numberOfPoints }).map(r => this.randomPoint(30));
this.bubbleChartData[0].data = data; this.bubbleChartData[0].data = data;
} }
} }