Browse Source

Basic Interactive Overview Graph

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

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

@ -61,6 +61,7 @@ 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 unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
@ -131,14 +132,17 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit {
this.errors = errors; this.errors = errors;
this.performance = performance; this.performance = performance;
this.historicalDataItems = chart.map( const multiplier =
({ date, netPerformanceInPercentageWithCurrencyEffect }) => { this.choice === 'netPerformanceInPercentageWithCurrencyEffect'
return { ? 100
date, : 1;
value: netPerformanceInPercentageWithCurrencyEffect * 100
}; this.historicalDataItems = chart.map((item) => {
} return {
); date: item.date,
value: item[this.choice] * multiplier
};
});
if ( if (
this.deviceType === 'mobile' && this.deviceType === 'mobile' &&
@ -155,4 +159,9 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
public onMetricClick(selectedChoice: string): void {
this.choice = selectedChoice; // update metric choice
this.update(); // rebuild historicalDataItems
}
} }

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

@ -99,6 +99,7 @@
[precision]="precision" [precision]="precision"
[showDetails]="showDetails" [showDetails]="showDetails"
[unit]="unit" [unit]="unit"
(metricClick)="onMetricClick($event)"
/> />
</div> </div>
</div> </div>

17
apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html

@ -30,7 +30,12 @@
'text-success': isAllTimeHigh 'text-success': isAllTimeHigh
}" }"
> >
<span #value id="value"></span> @if (!showDetails) {
<span #value id="value"></span>
}
@if (showDetails) {
<span #value id="value" (click)="onMetricClick('value')"></span>
}
</div> </div>
<div class="currency-container flex-grow-1 px-1"> <div class="currency-container flex-grow-1 px-1">
{{ unit }} {{ unit }}
@ -38,7 +43,10 @@
</div> </div>
@if (showDetails) { @if (showDetails) {
<div class="row"> <div class="row">
<div class="d-flex col justify-content-end"> <div
class="d-flex col justify-content-end"
(click)="onMetricClick('netPerformanceWithCurrencyEffect')"
>
<gf-value <gf-value
[colorizeSign]="true" [colorizeSign]="true"
[isCurrency]="true" [isCurrency]="true"
@ -50,7 +58,10 @@
" "
/> />
</div> </div>
<div class="col"> <div
class="col"
(click)="onMetricClick('netPerformanceInPercentageWithCurrencyEffect')"
>
<gf-value <gf-value
[colorizeSign]="true" [colorizeSign]="true"
[isPercent]="true" [isPercent]="true"

7
apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts

@ -17,6 +17,8 @@ import {
ElementRef, ElementRef,
Input, Input,
OnChanges, OnChanges,
Output,
EventEmitter,
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import { IonIcon } from '@ionic/angular/standalone'; import { IonIcon } from '@ionic/angular/standalone';
@ -44,6 +46,7 @@ export class GfPortfolioPerformanceComponent implements OnChanges {
@Input() precision: number; @Input() precision: number;
@Input() showDetails: boolean; @Input() showDetails: boolean;
@Input() unit: string; @Input() unit: string;
@Output() metricClick = new EventEmitter<string>();
@ViewChild('value') value: ElementRef; @ViewChild('value') value: ElementRef;
@ -95,4 +98,8 @@ export class GfPortfolioPerformanceComponent implements OnChanges {
title: $localize`Market data is delayed for` title: $localize`Market data is delayed for`
}); });
} }
public onMetricClick(selectedChoice: string): void {
this.metricClick.emit(selectedChoice); // notify parent
}
} }

Loading…
Cancel
Save