From 263d3d15abe88b27e54fe6313357ac75838d055e Mon Sep 17 00:00:00 2001 From: Felix Date: Wed, 14 Aug 2019 15:43:41 +0100 Subject: [PATCH] yeet --- .../dashboard/dashboard-customer.component.ts | 8 +++++ .../more-graphs-and-tables.component.ts | 29 +++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/app/dashboard/dashboard-customer.component.ts b/src/app/dashboard/dashboard-customer.component.ts index e9dccf8..4b77535 100644 --- a/src/app/dashboard/dashboard-customer.component.ts +++ b/src/app/dashboard/dashboard-customer.component.ts @@ -121,6 +121,14 @@ export class DashboardCustomerComponent implements OnInit { // Graph widgets public widgetList = [ + { + type: 'graph', + name: 'total_duration', + duration: '400', + icon: 'icon-diamond', + title: '(test) last 400 days', + dataType: DataType.currency, + }, { type: 'graph', name: 'total_last_week', diff --git a/src/app/dashboard/more-graphs-and-tables.component.ts b/src/app/dashboard/more-graphs-and-tables.component.ts index 92a2e18..a2f1bcc 100644 --- a/src/app/dashboard/more-graphs-and-tables.component.ts +++ b/src/app/dashboard/more-graphs-and-tables.component.ts @@ -24,7 +24,7 @@ export class MoreStuffComponent implements OnInit { ngOnInit(): void { this.loadYearSpend(); - this.loadSupplierBubble(); + this.loadSupplierBubble(true, new Date('January 1, 2018'), new Date('January 1, 2019')); // pass start and end date ranges to this as Date()s this.loadSupplierHistory(); } @@ -51,9 +51,32 @@ export class MoreStuffComponent implements OnInit { * Supplier Bubble Chart Setup */ - private loadSupplierBubble() { + private loadSupplierBubble(bool useRange, Date start_range, Date end_range) { this.api.loadMiscUrl('organisation/external/supplier_count').subscribe( result => { + + if (useRange) { + let ranged_data = []; + + for (var i = 0; i < ranged_data.data.count; i++) { + result.data.map(item => { + if (ranged_data.data[i].date >= start_range && ranged_data.data[i].date <= end_range) { + ranged_data.push({ + t: item.date, + r: item.value > 1000000 ? (item.value / 1000000) + 10 : (item.value / 100000) + 5, + supplier: item.seller, + y: item.count, + value: item.value, + count: item.count, + }); + } + } + } + + this.supplierBubbleChartData[0].data = ranged_data; + + } else { + console.log(result.data); let graph_data = []; result.data.map(item => { @@ -68,6 +91,8 @@ export class MoreStuffComponent implements OnInit { }); console.log(graph_data); this.supplierBubbleChartData[0].data = graph_data; + + } } ) }