Browse Source

Refactoring

pull/3177/head
Thomas Kaul 1 year ago
parent
commit
62e40e5bc9
  1. 2
      apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html
  2. 8
      apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts
  3. 5
      apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts
  4. 2
      apps/client/src/app/pages/portfolio/analysis/analysis-page.html

2
apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html

@ -20,7 +20,7 @@
<mat-select <mat-select
name="benchmark" name="benchmark"
[disabled]="user?.subscription?.type === 'Basic'" [disabled]="user?.subscription?.type === 'Basic'"
[value]="benchmark" [value]="benchmark?.id"
(selectionChange)="onChangeBenchmark($event.value)" (selectionChange)="onChangeBenchmark($event.value)"
> >
<mat-option [value]="null" /> <mat-option [value]="null" />

8
apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts

@ -46,8 +46,8 @@ import annotationPlugin from 'chartjs-plugin-annotation';
styleUrls: ['./benchmark-comparator.component.scss'] styleUrls: ['./benchmark-comparator.component.scss']
}) })
export class BenchmarkComparatorComponent implements OnChanges, OnDestroy { export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {
@Input() benchmark: Partial<SymbolProfile>;
@Input() benchmarkDataItems: LineChartItem[] = []; @Input() benchmarkDataItems: LineChartItem[] = [];
@Input() benchmark: string;
@Input() benchmarks: Partial<SymbolProfile>[]; @Input() benchmarks: Partial<SymbolProfile>[];
@Input() colorScheme: ColorScheme; @Input() colorScheme: ColorScheme;
@Input() daysInMarket: number; @Input() daysInMarket: number;
@ -98,10 +98,6 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {
} }
private initialize() { private initialize() {
const benchmarkAssetProfile = this.benchmarks.find(({ id }) => {
return id === this.benchmark;
});
const data: ChartData<'line'> = { const data: ChartData<'line'> = {
datasets: [ datasets: [
{ {
@ -120,7 +116,7 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {
data: this.benchmarkDataItems.map(({ date, value }) => { data: this.benchmarkDataItems.map(({ date, value }) => {
return { x: parseDate(date).getTime(), y: value }; return { x: parseDate(date).getTime(), y: value };
}), }),
label: benchmarkAssetProfile?.name ?? $localize`Benchmark` label: this.benchmark?.name ?? $localize`Benchmark`
} }
] ]
}; };

5
apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts

@ -32,6 +32,7 @@ import { takeUntil } from 'rxjs/operators';
templateUrl: './analysis-page.html' templateUrl: './analysis-page.html'
}) })
export class AnalysisPageComponent implements OnDestroy, OnInit { export class AnalysisPageComponent implements OnDestroy, OnInit {
public benchmark: Partial<SymbolProfile>;
public benchmarkDataItems: HistoricalDataItem[] = []; public benchmarkDataItems: HistoricalDataItem[] = [];
public benchmarks: Partial<SymbolProfile>[]; public benchmarks: Partial<SymbolProfile>[];
public bottom3: Position[]; public bottom3: Position[];
@ -122,6 +123,10 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
if (state?.user) { if (state?.user) {
this.user = state.user; this.user = state.user;
this.benchmark = this.benchmarks.find(({ id }) => {
return id === this.user.settings?.benchmark;
});
this.update(); this.update();
} }
}); });

2
apps/client/src/app/pages/portfolio/analysis/analysis-page.html

@ -4,7 +4,7 @@
<div class="col-lg"> <div class="col-lg">
<gf-benchmark-comparator <gf-benchmark-comparator
class="h-100" class="h-100"
[benchmark]="user?.settings?.benchmark" [benchmark]="benchmark"
[benchmarkDataItems]="benchmarkDataItems" [benchmarkDataItems]="benchmarkDataItems"
[benchmarks]="benchmarks" [benchmarks]="benchmarks"
[colorScheme]="user?.settings?.colorScheme" [colorScheme]="user?.settings?.colorScheme"

Loading…
Cancel
Save