Feature/add allocations by platform chart (#1915)
* Add allocations by platform * Update changelog
This commit is contained in:
@@ -20,7 +20,7 @@ import {
|
||||
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
||||
import { Market } from '@ghostfolio/common/types';
|
||||
import { translate } from '@ghostfolio/ui/i18n';
|
||||
import { Account, AssetClass, DataSource } from '@prisma/client';
|
||||
import { Account, AssetClass, DataSource, Platform } from '@prisma/client';
|
||||
import { isNumber } from 'lodash';
|
||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||
import { Subject } from 'rxjs';
|
||||
@@ -55,6 +55,12 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
|
||||
[key in Market]: { name: string; value: number };
|
||||
};
|
||||
public placeholder = '';
|
||||
public platforms: {
|
||||
[id: string]: Pick<Platform, 'name'> & {
|
||||
id: string;
|
||||
value: number;
|
||||
};
|
||||
};
|
||||
public portfolioDetails: PortfolioDetails;
|
||||
public positions: {
|
||||
[symbol: string]: Pick<
|
||||
@@ -230,6 +236,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
|
||||
value: undefined
|
||||
}
|
||||
};
|
||||
this.platforms = {};
|
||||
this.positions = {};
|
||||
this.sectors = {
|
||||
[UNKNOWN_KEY]: {
|
||||
@@ -371,6 +378,25 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
|
||||
};
|
||||
}
|
||||
|
||||
for (const [
|
||||
id,
|
||||
{ name, valueInBaseCurrency, valueInPercentage }
|
||||
] of Object.entries(this.portfolioDetails.platforms)) {
|
||||
let value = 0;
|
||||
|
||||
if (this.hasImpersonationId) {
|
||||
value = valueInPercentage;
|
||||
} else {
|
||||
value = valueInBaseCurrency;
|
||||
}
|
||||
|
||||
this.platforms[id] = {
|
||||
id,
|
||||
name,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
const marketsTotal =
|
||||
this.markets.developedMarkets.value +
|
||||
this.markets.emergingMarkets.value +
|
||||
|
@@ -38,18 +38,18 @@
|
||||
<div class="col-md-4">
|
||||
<mat-card appearance="outlined" class="mb-3">
|
||||
<mat-card-header class="overflow-hidden w-100">
|
||||
<mat-card-title class="text-truncate" i18n>By Account</mat-card-title>
|
||||
<mat-card-title class="text-truncate" i18n
|
||||
>By Platform</mat-card-title
|
||||
>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<gf-portfolio-proportion-chart
|
||||
cursor="pointer"
|
||||
[baseCurrency]="user?.settings?.baseCurrency"
|
||||
[colorScheme]="user?.settings?.colorScheme"
|
||||
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
|
||||
[keys]="['id']"
|
||||
[locale]="user?.settings?.locale"
|
||||
[positions]="accounts"
|
||||
(proportionChartClicked)="onAccountChartClicked($event)"
|
||||
[positions]="platforms"
|
||||
></gf-portfolio-proportion-chart>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@@ -250,6 +250,25 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<mat-card appearance="outlined" class="mb-3">
|
||||
<mat-card-header class="overflow-hidden w-100">
|
||||
<mat-card-title class="text-truncate" i18n>By Account</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<gf-portfolio-proportion-chart
|
||||
cursor="pointer"
|
||||
[baseCurrency]="user?.settings?.baseCurrency"
|
||||
[colorScheme]="user?.settings?.colorScheme"
|
||||
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
|
||||
[keys]="['id']"
|
||||
[locale]="user?.settings?.locale"
|
||||
[positions]="accounts"
|
||||
(proportionChartClicked)="onAccountChartClicked($event)"
|
||||
></gf-portfolio-proportion-chart>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<mat-card appearance="outlined" class="mb-3">
|
||||
<mat-card-header class="overflow-hidden w-100">
|
||||
|
Reference in New Issue
Block a user