fix
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
// angular
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
// libs
|
||||
import {
|
||||
ApexAxisChartSeries,
|
||||
ApexChart,
|
||||
@@ -16,6 +20,10 @@ import {
|
||||
ApexNonAxisChartSeries,
|
||||
} from 'ng-apexcharts';
|
||||
|
||||
// app
|
||||
import { ApiRoutes } from '../../api-routes';
|
||||
import { DashboardModel } from '../../model/dashboard.model';
|
||||
|
||||
export type ChartOptions = {
|
||||
series: ApexAxisChartSeries;
|
||||
series2: ApexNonAxisChartSeries;
|
||||
@@ -43,15 +51,35 @@ export type ChartOptions = {
|
||||
export class Dashboard2Component implements OnInit {
|
||||
lineChartOptions!: Partial<ChartOptions>;
|
||||
pieChartOptions!: Partial<ChartOptions>;
|
||||
dashboardModel?: DashboardModel;
|
||||
|
||||
// color: ["#3FA7DC", "#F6A025", "#9BC311"],
|
||||
constructor() {
|
||||
//constructor
|
||||
constructor(private httpClient: HttpClient) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.chart1();
|
||||
this.chart2();
|
||||
|
||||
this.httpClient
|
||||
.get<DashboardModel>(ApiRoutes.Dashboard)
|
||||
.subscribe(data => {
|
||||
data.incomeChange = this.calcChanges(data.incomeLastWeek, data.incomePreviousWeek);
|
||||
data.outcomeChange = this.calcChanges(data.outcomeLastWeek, data.outcomePreviousWeek);
|
||||
this.dashboardModel = data;
|
||||
});
|
||||
}
|
||||
|
||||
private calcChanges(newValue: number, oldValue: number): number {
|
||||
if (newValue > oldValue) {
|
||||
return (newValue - oldValue) / oldValue * 100;
|
||||
}
|
||||
else if (newValue < oldValue) {
|
||||
return (oldValue - newValue) / oldValue * 100;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private chart1() {
|
||||
|
||||
Reference in New Issue
Block a user