wip all purchases

This commit is contained in:
Tom Slater 2019-07-12 17:01:40 +01:00
parent e7441bf47a
commit 7740d9ec2d
2 changed files with 30 additions and 9 deletions

View file

@ -165,11 +165,11 @@
</div><!--/.row--> </div><!--/.row-->
<div class="chart-wrapper"> <div class="chart-wrapper">
<canvas baseChart class="chart" <canvas baseChart class="chart"
[datasets]="barChartDataCategory" [datasets]="barChartDataCategoryAll"
[labels]="barChartLabelsCategory" [labels]="barChartLabelsCategoryAll"
[options]="barChartOptionsCategory" [options]="barChartOptionsCategoryAll"
[legend]="barChartLegendCategory" [legend]="barChartLegendCategoryAll"
[chartType]="barChartTypeCategory" [chartType]="barChartTypeCategoryAll"
(chartHover)="chartHovered($event)" (chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)"></canvas> (chartClick)="chartClicked($event)"></canvas>
</div> </div>

View file

@ -1,8 +1,6 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { Router, NavigationEnd } from "@angular/router"; import { Router, NavigationEnd } from "@angular/router";
import { CurrencyPipe } from '@angular/common'; import { CurrencyPipe } from '@angular/common';
import { ChartOptions, ChartType, ChartDataSets } from 'chart.js';
import { Color, Label } from 'ng2-charts';
import { GraphWidget } from '../widgets/graph-widget.component'; import { GraphWidget } from '../widgets/graph-widget.component';
import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component'; import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component';
import { GraphPanel } from '../panels/graph-panel.component'; import { GraphPanel } from '../panels/graph-panel.component';
@ -68,6 +66,7 @@ export class DashboardComponent {
public doughnutChartDataCategory: any[] = []; public doughnutChartDataCategory: any[] = [];
public doughnutChartLabelsCategory: string[] = []; public doughnutChartLabelsCategory: string[] = [];
public doughnutChartOptionsCategory:any = { public doughnutChartOptionsCategory:any = {
tooltips: { tooltips: {
callbacks: { callbacks: {
@ -130,6 +129,11 @@ export class DashboardComponent {
public barChartDataCategory:any[]=[]; public barChartDataCategory:any[]=[];
public barChartLabelsCategory:string[] = []; public barChartLabelsCategory:string[] = [];
public barChartDataCategoryAll:string = 'bar'
public barChartLegendCategoryAll:boolean = false;
public barChartDataCategoryAll:any[]=[];
public barChartLabelsCategoryAll:string[] = [];
public lineChartDataSector: ChartDataSets[] = [ public lineChartDataSector: ChartDataSets[] = [
{ data: [], label: '' }, { data: [], label: '' },
@ -239,6 +243,23 @@ export class DashboardComponent {
); );
} }
private setChartDataCat(dataCat: any) {
this.barChartLabelsCategoryAll = Object.keys(dataCat);
let barChartDataCategoryInitial = Object.keys(dataCat).map(key => dataCat[key]);
this.barChartDataCategoryAll = [
{data: barChartDataCategoryInitial, label: 'Series A'},
];
this.showCategoryBarChart = true;
if (this.weekList1) {
let n = 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 setChartDataCat(dataCat: any) { private setChartDataCat(dataCat: any) {
this.barChartLabelsCategory = Object.keys(dataCat); this.barChartLabelsCategory = Object.keys(dataCat);
let barChartDataCategoryInitial = Object.keys(dataCat).map(key => dataCat[key]); let barChartDataCategoryInitial = Object.keys(dataCat).map(key => dataCat[key]);
@ -247,7 +268,7 @@ export class DashboardComponent {
]; ];
this.showCategoryBarChart = true; this.showCategoryBarChart = true;
if (this.weekList1) { if (this.weekList1) {
let doughnutChartDataCategoryInitial = this.weekList1.map(function(a) {return a.value;}); let n = this.weekList1.map(function(a) {return a.value;});
this.doughnutChartDataCategory = [ this.doughnutChartDataCategory = [
{data: doughnutChartDataCategoryInitial, label: 'Series A'}, {data: doughnutChartDataCategoryInitial, label: 'Series A'},
]; ];
@ -261,7 +282,7 @@ export class DashboardComponent {
this.barChartLabelsCategory = Object.keys(dataSec); this.barChartLabelsCategory = Object.keys(dataSec);
let lineChartDataSectorInitial = Object.keys(dataSec).map(key => dataSec[key]); let lineChartDataSectorInitial = Object.keys(dataSec).map(key => dataSec[key]);
this.lineChartDataSector = [ this.lineChartDataSector = [
{data: lineChartDataSectorInitial, label: 'Series A'}, {data: barChartDataCategoryInitial, label: 'Series A'},
]; ];
this.showCategoryBarChart = true; this.showCategoryBarChart = true;
if (this.weekList1) { if (this.weekList1) {