diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts index 44f7280473..c4a29bde90 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts @@ -10,7 +10,7 @@ import { DATE_FORMAT, downloadAsFile } from '@ghostfolio/common/helper'; import { AccountBalancesResponse, Activity, - HistoricalDataItem, + LineChartItem, PortfolioPosition, User } from '@ghostfolio/common/interfaces'; @@ -99,7 +99,7 @@ export class GfAccountDetailDialogComponent implements OnInit { protected equity: number | null; protected equityPrecision = 2; protected hasPermissionToDeleteAccountBalance: boolean; - protected historicalDataItems: HistoricalDataItem[]; + protected historicalDataItems: LineChartItem[]; protected holdings: PortfolioPosition[]; protected interestInBaseCurrency: number; protected interestInBaseCurrencyPrecision = 2; @@ -364,12 +364,12 @@ export class GfAccountDetailDialogComponent implements OnInit { portfolioPerformance.chart && portfolioPerformance.chart.length > 0 ) { - this.historicalDataItems = portfolioPerformance.chart.map( - ({ date, netWorth, netWorthInPercentage }) => ({ + this.historicalDataItems = portfolioPerformance.chart + .map(({ date, netWorth, netWorthInPercentage }) => ({ date, value: isNumber(netWorth) ? netWorth : netWorthInPercentage - }) - ); + })) + .filter((item): item is LineChartItem => isNumber(item.value)); } else { this.historicalDataItems = this.accountBalances.map( ({ date, valueInBaseCurrency }) => { diff --git a/apps/client/src/app/components/investment-chart/investment-chart.component.ts b/apps/client/src/app/components/investment-chart/investment-chart.component.ts index a1dc6a28f9..34500422ed 100644 --- a/apps/client/src/app/components/investment-chart/investment-chart.component.ts +++ b/apps/client/src/app/components/investment-chart/investment-chart.component.ts @@ -59,7 +59,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy { @Input() public benchmarkDataLabel = ''; @Input() public colorScheme?: ColorScheme; @Input() public currency?: string; - @Input() public groupBy: GroupBy; + @Input() public groupBy?: GroupBy; @Input() public historicalDataItems: LineChartItem[] = []; @Input() public isInPercentage?: boolean = false; @Input() public isLoading = false; 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 880753cce5..1211473faf 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 @@ -9,6 +9,7 @@ import { canOpenHoldingDetail } from '@ghostfolio/common/helper'; import { HistoricalDataItem, InvestmentItem, + LineChartItem, PortfolioInvestmentsResponse, PortfolioPerformance, PortfolioPosition, @@ -101,8 +102,8 @@ export class GfAnalysisPageComponent implements OnInit { ]; protected performance: PortfolioPerformance; protected readonly PerformanceCalculationType = PerformanceCalculationType; - protected performanceDataItems: HistoricalDataItem[]; - protected performanceDataItemsInPercentage: HistoricalDataItem[]; + protected performanceDataItems: LineChartItem[]; + protected performanceDataItemsInPercentage: LineChartItem[]; protected readonly portfolioEvolutionDataLabel = $localize`Investment`; protected precision = 2; protected savingsRatePerMonth: number | undefined; @@ -378,18 +379,24 @@ export class GfAnalysisPageComponent implements OnInit { }); } - this.performanceDataItems.push({ + const value = isNumber(valueWithCurrencyEffect) + ? valueWithCurrencyEffect + : valueInPercentage; + + if (isNumber(value)) { + this.performanceDataItems.push({ + date, + value + }); + } + } + + if (isNumber(netPerformanceInPercentageWithCurrencyEffect)) { + this.performanceDataItemsInPercentage.push({ date, - value: isNumber(valueWithCurrencyEffect) - ? valueWithCurrencyEffect - : valueInPercentage + value: netPerformanceInPercentageWithCurrencyEffect }); } - - this.performanceDataItemsInPercentage.push({ - date, - value: netPerformanceInPercentageWithCurrencyEffect - }); } if (