|
|
|
|
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
|
|
import {PastYearMonthlyData} from '../models/PastYearMonthly.model'; |
|
|
|
|
|
import {Observable} from 'rxjs'; |
|
|
|
|
|
import {HttpClient} from '@angular/common/http'; |
|
|
|
|
|
import {AuthService} from '../service/auth.service'; |
|
|
|
|
|
import {map} from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'app-chart-past-year-monthly-performance', |
|
|
selector: 'app-chart-past-year-monthly-performance', |
|
|
|
|
|
|
|
|
styleUrls: ['./chart-past-year-monthly-performance.component.scss'] |
|
|
styleUrls: ['./chart-past-year-monthly-performance.component.scss'] |
|
|
}) |
|
|
}) |
|
|
export class ChartPastYearMonthlyPerformanceComponent implements OnInit { |
|
|
export class ChartPastYearMonthlyPerformanceComponent implements OnInit { |
|
|
|
|
|
pastYearData: Observable<PastYearMonthlyData[]>; |
|
|
|
|
|
|
|
|
constructor() { } |
|
|
|
|
|
|
|
|
constructor(private http: HttpClient, private auth: AuthService) { } |
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
ngOnInit(): void { |
|
|
|
|
|
this.pastYearData = this.getPastYearMonthly(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line:typedef |
|
|
|
|
|
private getPastYearMonthly(): Observable<PastYearMonthlyData[]> { |
|
|
|
|
|
return this.http.get<PastYearMonthlyData[]>(this.auth.getUrl('chart/past-year-monthly')).pipe(map( |
|
|
|
|
|
data => { |
|
|
|
|
|
let ret = []; |
|
|
|
|
|
data.forEach( (value: PastYearMonthlyData , index: number ) => { |
|
|
|
|
|
let a = { |
|
|
|
|
|
Period: value.Period, |
|
|
|
|
|
Amount: value.Amount / 1000, |
|
|
|
|
|
Summary: '', |
|
|
|
|
|
}; |
|
|
|
|
|
if (index > 0) { |
|
|
|
|
|
a.Amount -= (data[index - 1].Amount / 1000); |
|
|
|
|
|
} |
|
|
|
|
|
ret.push(a); |
|
|
|
|
|
}); |
|
|
|
|
|
return ret; |
|
|
|
|
|
} |
|
|
|
|
|
)); |
|
|
} |
|
|
} |
|
|
public cashFlowData = [{ |
|
|
|
|
|
period: 'beginning', |
|
|
|
|
|
amount: 50000 |
|
|
|
|
|
}, { |
|
|
|
|
|
period: 'Jan', |
|
|
|
|
|
amount: 17000 |
|
|
|
|
|
}, { |
|
|
|
|
|
period: 'Feb', |
|
|
|
|
|
amount: 14000 |
|
|
|
|
|
}, { |
|
|
|
|
|
period: 'Mar', |
|
|
|
|
|
amount: -12000 |
|
|
|
|
|
}, { |
|
|
|
|
|
period: 'Q1', |
|
|
|
|
|
summary: 'runningTotal' |
|
|
|
|
|
}, { |
|
|
|
|
|
period: 'Apr', |
|
|
|
|
|
amount: -22000 |
|
|
|
|
|
}, { |
|
|
|
|
|
period: 'May', |
|
|
|
|
|
amount: -18000 |
|
|
|
|
|
}, { |
|
|
|
|
|
period: 'Jun', |
|
|
|
|
|
amount: 10000 |
|
|
|
|
|
}, { |
|
|
|
|
|
period: 'Q2', |
|
|
|
|
|
summary: 'runningTotal' |
|
|
|
|
|
}, { |
|
|
|
|
|
period: 'Ending', |
|
|
|
|
|
summary: 'total' |
|
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
|
|
public pointColor(point: any): string { |
|
|
public pointColor(point: any): string { |
|
|
const summary = point.dataItem.summary; |
|
|
const summary = point.dataItem.summary; |
|
|
|
|
|
|
|
|
if (point.value > 0) { |
|
|
if (point.value > 0) { |
|
|
return 'green'; |
|
|
return 'green'; |
|
|
} else { |
|
|
} else { |
|
|
return 'red'; |
|
|
|
|
|
|
|
|
return 'lightyellow'; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |