From 7d0b672471abb57ae485cb2f927fcad6cebb8404 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Tue, 28 Mar 2023 21:10:15 +0200 Subject: [PATCH] Ignore first item in portfolio evolution chart --- .../analysis/analysis-page.component.ts | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) 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 ae60a5e2a..74371da9d 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 @@ -308,18 +308,24 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { this.performanceDataItems = []; this.performanceDataItemsInPercentage = []; - for (const { - date, - netPerformanceInPercentage, - totalInvestment, - value, - valueInPercentage - } of chart) { - this.investments.push({ date, investment: totalInvestment }); - this.performanceDataItems.push({ + for (const [ + index, + { date, - value: isNumber(value) ? value : valueInPercentage - }); + netPerformanceInPercentage, + totalInvestment, + value, + valueInPercentage + } + ] of chart.entries()) { + if (index > 0 || this.user?.settings?.dateRange === 'max') { + // Ignore first item where value is 0 + this.investments.push({ date, investment: totalInvestment }); + this.performanceDataItems.push({ + date, + value: isNumber(value) ? value : valueInPercentage + }); + } this.performanceDataItemsInPercentage.push({ date, value: netPerformanceInPercentage