Browse Source

update unit in graph caption

pull/5570/head
Batwam 3 months ago
parent
commit
c4603140da
No known key found for this signature in database GPG Key ID: 7D9EDF6264938D38
  1. 17
      apps/client/src/app/components/home-overview/home-overview.component.ts
  2. 2
      apps/client/src/app/components/home-overview/home-overview.html

17
apps/client/src/app/components/home-overview/home-overview.component.ts

@ -61,7 +61,8 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit {
public showDetails = false; public showDetails = false;
public unit: string; public unit: string;
public user: User; public user: User;
private choice: string = 'netPerformanceInPercentageWithCurrencyEffect'; private graph_type: string = 'netPerformanceInPercentageWithCurrencyEffect';
public graph_unit: string;
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
@ -132,15 +133,19 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit {
this.errors = errors; this.errors = errors;
this.performance = performance; this.performance = performance;
const multiplier = const graph_multiplier =
this.choice === 'netPerformanceInPercentageWithCurrencyEffect' this.graph_type === 'netPerformanceInPercentageWithCurrencyEffect'
? 100 ? 100
: 1; : 1;
this.graph_unit =
this.graph_type === 'netPerformanceInPercentageWithCurrencyEffect'
? '%'
: this.unit;
this.historicalDataItems = chart.map((item) => { this.historicalDataItems = chart.map((item) => {
return { return {
date: item.date, date: item.date,
value: item[this.choice] * multiplier value: item[this.graph_type] * graph_multiplier
}; };
}); });
@ -160,8 +165,8 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
public onMetricClick(selectedChoice: string): void { public onMetricClick(selectedgraph_type: string): void {
this.choice = selectedChoice; // update metric choice this.graph_type = selectedgraph_type; // update metric graph_type
this.update(); // rebuild historicalDataItems this.update(); // rebuild historicalDataItems
} }
} }

2
apps/client/src/app/components/home-overview/home-overview.html

@ -69,7 +69,6 @@
<div class="chart-container mx-auto position-relative"> <div class="chart-container mx-auto position-relative">
<gf-line-chart <gf-line-chart
class="position-absolute" class="position-absolute"
unit="%"
[colorScheme]="user?.settings?.colorScheme" [colorScheme]="user?.settings?.colorScheme"
[hidden]="historicalDataItems?.length === 0" [hidden]="historicalDataItems?.length === 0"
[historicalDataItems]="historicalDataItems" [historicalDataItems]="historicalDataItems"
@ -81,6 +80,7 @@
[showLoader]="false" [showLoader]="false"
[showXAxis]="false" [showXAxis]="false"
[showYAxis]="false" [showYAxis]="false"
[unit]="graph_unit"
/> />
</div> </div>
</div> </div>

Loading…
Cancel
Save