From 8a062e03ab687c0cc4c2c71848257bf6a3de11b5 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:38:35 +0100 Subject: [PATCH] Feature/add benchmark name to tooltip of benchmark comparator (#3177) * Add benchmark name to chart tooltip * Update changelog --- CHANGELOG.md | 1 + .../benchmark-comparator/benchmark-comparator.component.html | 2 +- .../benchmark-comparator/benchmark-comparator.component.ts | 4 ++-- .../app/pages/portfolio/analysis/analysis-page.component.ts | 5 +++++ .../src/app/pages/portfolio/analysis/analysis-page.html | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98835da83..f00b03764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Improved the chart tooltip of the benchmark comparator by adding the benchmark name - Upgraded `angular` from version `17.1.3` to `17.2.4` - Upgraded `Nx` from version `18.0.4` to `18.1.2` diff --git a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html index c34fcf274..2f74037f8 100644 --- a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html +++ b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html @@ -20,7 +20,7 @@ diff --git a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts index 8a9c8f8dd..fdf20023e 100644 --- a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts +++ b/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'] }) export class BenchmarkComparatorComponent implements OnChanges, OnDestroy { + @Input() benchmark: Partial; @Input() benchmarkDataItems: LineChartItem[] = []; - @Input() benchmark: string; @Input() benchmarks: Partial[]; @Input() colorScheme: ColorScheme; @Input() daysInMarket: number; @@ -116,7 +116,7 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy { data: this.benchmarkDataItems.map(({ date, value }) => { return { x: parseDate(date).getTime(), y: value }; }), - label: $localize`Benchmark` + label: this.benchmark?.name ?? $localize`Benchmark` } ] }; diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts index 96c7c01dc..c0569b9f4 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts @@ -32,6 +32,7 @@ import { takeUntil } from 'rxjs/operators'; templateUrl: './analysis-page.html' }) export class AnalysisPageComponent implements OnDestroy, OnInit { + public benchmark: Partial; public benchmarkDataItems: HistoricalDataItem[] = []; public benchmarks: Partial[]; public bottom3: Position[]; @@ -122,6 +123,10 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { if (state?.user) { this.user = state.user; + this.benchmark = this.benchmarks.find(({ id }) => { + return id === this.user.settings?.benchmark; + }); + this.update(); } }); diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html index 692adeb7a..5f6acdbe2 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html @@ -4,7 +4,7 @@