Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Add a new symbol allocation chart (#326)
Ivo Valchevb1187cf8808f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 661754e4b1..7c4528a8bc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added- Added a link below the holdings to manage the transactions+- Added the allocation chart by symbol### Fixeddiff --git a/apps/client/src/app/components/portfolio-proportion-chart/portfolio-proportion-chart.component.ts b/apps/client/src/app/components/portfolio-proportion-chart/portfolio-proportion-chart.component.tsindex dd50d67c89..c1df834556 100644--- a/apps/client/src/app/components/portfolio-proportion-chart/portfolio-proportion-chart.component.ts+++ b/apps/client/src/app/components/portfolio-proportion-chart/portfolio-proportion-chart.component.ts@@ -167,7 +167,8 @@ export class PortfolioProportionChartComponent// Reuse coloritem.color = this.colorMap[symbol];} else {- const color = this.getColorPalette()[index];+ const color =+ this.getColorPalette()[index % this.getColorPalette().length];// Store color for reusethis.colorMap[symbol] = color;diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.tsindex f1dd34f876..812bf44acb 100644--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts@@ -42,6 +42,10 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {public sectors: {[name: string]: { name: string; value: number };};+ public symbols: {+ [name: string]: { name: string; value: number };+ };+public user: User;private unsubscribeSubject = new Subject<void>();@@ -114,6 +118,12 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {value: 0}};+ this.symbols = {+ [UNKNOWN_KEY]: {+ name: UNKNOWN_KEY,+ value: 0+ }+ };for (const [name, { current, original }] of Object.entries(this.portfolioDetails.accounts@@ -208,6 +218,15 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {: this.portfolioDetails.holdings[symbol].value;}}++ if (position.assetSubClass !== AssetClass.CASH) {+ // Prepare analysis data by symbols except for cash++ this.symbols[symbol] = {+ name: symbol,+ value: aPeriod === 'original' ? position.investment : position.value+ };+ }}}diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html b/apps/client/src/app/pages/portfolio/allocations/allocations-page.htmlindex f9fd44f088..6d16956be7 100644--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html@@ -5,6 +5,29 @@</div></div><div class="proportion-charts row">+ <div class="col-md-6">+ <mat-card class="mb-3">+ <mat-card-header class="w-100">+ <mat-card-title i18n>By Symbol</mat-card-title>+ <gf-toggle+ [defaultValue]="period"+ [isLoading]="false"+ [options]="periodOptions"+ (change)="onChangePeriod($event.value)"+ ></gf-toggle>+ </mat-card-header>+ <mat-card-content>+ <gf-portfolio-proportion-chart+ [baseCurrency]="user?.settings?.baseCurrency"+ [isInPercent]="false"+ [keys]="['name']"+ [locale]="user?.settings?.locale"+ [positions]="symbols"+ ></gf-portfolio-proportion-chart>+ </mat-card-content>+ </mat-card>+ </div>+<div class="col-md-6"><mat-card class="mb-3"><mat-card-header class="w-100">