From d36f5f7a03c00d0283193a6be7507c57ba2a2385 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:16:12 +0200 Subject: [PATCH] Fix scaleX calculation --- .../investment-chart/investment-chart.component.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 15a4a6f9a..e3a1e87c7 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 @@ -156,10 +156,15 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy { let scaleXMin: string; if (this.daysInMarket) { - const minDate = min([ - parseDate(first(this.investments)?.date), + const dates = [ subDays(new Date().setHours(0, 0, 0, 0), this.daysInMarket) - ]); + ]; + + if (first(this.investments)?.date) { + dates.push(parseDate(first(this.investments)?.date)); + } + + const minDate = min(dates); scaleXMin = isValid(minDate) ? minDate.toISOString() : undefined; }