debugging custom range

This commit is contained in:
Felix 2019-08-15 12:09:46 +01:00
parent 444b745ae1
commit df30b12971
2 changed files with 42 additions and 44 deletions

View file

@ -6,8 +6,8 @@
<h4 class="card-title mb-0">Spend amount and number of purchases by supplier name</h4> <h4 class="card-title mb-0">Spend amount and number of purchases by supplier name</h4>
</div> </div>
<div class="col-sm-5 hidden-sm-down"> <div class="col-sm-5 hidden-sm-down">
<input type="date" [(ngModel)]="bubbleChartBegin" (ngModelChange)="bubbleChartUpdate()"> <input type="date" (ngModel)="bubbleChartBegin" (ngModelChange)="bubbleChartUpdate()">
<input type="date" [(ngModel)]="bubbleChartEnd" (ngModelChange)="bubbleChartUpdate()"> <input type="date" (ngModel)="bubbleChartEnd" (ngModelChange)="bubbleChartUpdate()">
</div> </div>
</div> </div>
<div> <div>

View file

@ -25,7 +25,7 @@ export class MoreStuffComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.loadYearSpend(); this.loadYearSpend();
// 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.loadSupplierBubble(true, new Date('January 1, 2018'), new Date('January 1, 2019')); // pass start and end date ranges to this as Date()s
this.loadSupplierBubble(false, new Date('January 1, 2018'), new Date('January 1, 2019')); // pass start and end date ranges to this as Date()s this.loadSupplierBubble(true, ('01-01-2018'), ('01-01-2019')); // pass start and end date ranges to this as Date()s
this.loadSupplierHistory(); this.loadSupplierHistory();
} }
@ -52,21 +52,24 @@ export class MoreStuffComponent implements OnInit {
* Supplier Bubble Chart Setup * Supplier Bubble Chart Setup
*/ */
private loadSupplierBubble(useRange: boolean, start_range : Date, end_range : Date) { private loadSupplierBubble(useRange: boolean, start_range : string, end_range : string) {
console.log("fetching data for bubble chart... (this takes a while)"); console.log("fetching data for bubble chart... this will take a while. custom range: " + useRange);
this.api.loadMiscUrl('organisation/external/supplier_count').subscribe( this.api.loadMiscUrl('organisation/external/supplier_count').subscribe(
result => { result => {
console.log("data fetched:"); let graph_data = [];
console.log(result.data);
if (useRange == true) { if (useRange == true) {
let ranged_data = []; console.log("using range " + start_range + " : " + end_range);
let start_date = new Date(start_range);
for (var i = 0; i < result.data.count; i++) { let end_date = new Date(end_range);
result.data.map(item=> { result.data.map(item=> {
if (result.data[i].date >= start_range && result.data[i].date <= end_range) { console.log(new Date(item.date));
ranged_data.push({ console.log(start_date);
console.log(item.date >= start_date);
if (new Date(item.date) >= start_date && new Date(item.date) <= end_date) {
graph_data.push({
t: item.date, t: item.date,
r: item.value > 1000000 ? (item.value / 1000000) + 10 : (item.value / 100000) + 5, r: item.value > 1000000 ? (item.value / 1000000) + 10 : (item.value / 100000) + 5,
supplier: item.seller, supplier: item.seller,
@ -76,13 +79,9 @@ export class MoreStuffComponent implements OnInit {
}); });
} }
}); });
}
this.supplierBubbleChartData[0].data = ranged_data;
this.supplierBubbleChartData[0].data = graph_data;
} else { } else {
let graph_data = [];
result.data.map(item => { result.data.map(item => {
graph_data.push({ graph_data.push({
t: item.date, t: item.date,
@ -93,10 +92,9 @@ export class MoreStuffComponent implements OnInit {
count: item.count, count: item.count,
}); });
}); });
console.log(graph_data);
this.supplierBubbleChartData[0].data = graph_data;
} }
this.supplierBubbleChartData[0].data = graph_data;
} }
) )
} }
@ -155,7 +153,7 @@ export class MoreStuffComponent implements OnInit {
let value_data = []; let value_data = [];
let count_data = []; let count_data = [];
console.log(result.data); console.log("Result being fetched.");
result.data.map(item => { result.data.map(item => {
value_data.push({ value_data.push({
t: item.date, t: item.date,
@ -176,7 +174,7 @@ export class MoreStuffComponent implements OnInit {
bubbleChartUpdate() { bubbleChartUpdate() {
// this is called when daterange is changed // this is called when daterange is changed
console.log("yeeeee"); console.log("Bubble chart updated.");
} }
public yearSpendChartData: any[] = [ public yearSpendChartData: any[] = [