|
|
@ -96,7 +96,8 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
protected isLoadingInvestmentTimelineChart: boolean; |
|
|
protected isLoadingInvestmentTimelineChart: boolean; |
|
|
protected isLoadingPerformanceTimelineChart: boolean; |
|
|
protected isLoadingPerformanceTimelineChart: boolean; |
|
|
protected isLoadingPortfolioPrompt: boolean; |
|
|
protected isLoadingPortfolioPrompt: boolean; |
|
|
protected readonly mode = signal<GroupBy>('month'); |
|
|
protected readonly dividendGroupBy = signal<GroupBy>('month'); |
|
|
|
|
|
protected readonly investmentGroupBy = signal<GroupBy>('month'); |
|
|
protected readonly modeOptions: ToggleOption<GroupBy>[] = [ |
|
|
protected readonly modeOptions: ToggleOption<GroupBy>[] = [ |
|
|
{ label: $localize`Monthly`, value: 'month' }, |
|
|
{ label: $localize`Monthly`, value: 'month' }, |
|
|
{ label: $localize`Yearly`, value: 'year' } |
|
|
{ label: $localize`Yearly`, value: 'year' } |
|
|
@ -142,7 +143,7 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
return undefined; |
|
|
return undefined; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return this.mode() === 'year' |
|
|
return this.investmentGroupBy() === 'year' |
|
|
? this.savingsRatePerMonth * 12 |
|
|
? this.savingsRatePerMonth * 12 |
|
|
: this.savingsRatePerMonth; |
|
|
: this.savingsRatePerMonth; |
|
|
} |
|
|
} |
|
|
@ -186,8 +187,13 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected onChangeGroupBy(aMode: GroupBy) { |
|
|
protected onChangeDividendGroupBy(aMode: GroupBy) { |
|
|
this.mode.set(aMode); |
|
|
this.dividendGroupBy.set(aMode); |
|
|
|
|
|
this.fetchDividendsAndInvestments(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected onChangeInvestmentGroupBy(aMode: GroupBy) { |
|
|
|
|
|
this.investmentGroupBy.set(aMode); |
|
|
this.fetchDividendsAndInvestments(); |
|
|
this.fetchDividendsAndInvestments(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -248,12 +254,12 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
forkJoin({ |
|
|
forkJoin({ |
|
|
dividends: this.dataService.fetchDividends({ |
|
|
dividends: this.dataService.fetchDividends({ |
|
|
filters: this.userService.getFilters(), |
|
|
filters: this.userService.getFilters(), |
|
|
groupBy: this.mode(), |
|
|
groupBy: this.dividendGroupBy(), |
|
|
range: this.user?.settings?.dateRange ?? DEFAULT_DATE_RANGE |
|
|
range: this.user?.settings?.dateRange ?? DEFAULT_DATE_RANGE |
|
|
}), |
|
|
}), |
|
|
investments: this.dataService.fetchInvestments({ |
|
|
investments: this.dataService.fetchInvestments({ |
|
|
filters: this.userService.getFilters(), |
|
|
filters: this.userService.getFilters(), |
|
|
groupBy: this.mode(), |
|
|
groupBy: this.investmentGroupBy(), |
|
|
range: this.user?.settings?.dateRange ?? DEFAULT_DATE_RANGE |
|
|
range: this.user?.settings?.dateRange ?? DEFAULT_DATE_RANGE |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
@ -263,6 +269,7 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
dividends: { dividends }, |
|
|
dividends: { dividends }, |
|
|
investments: { investments, savingsRate, streaks } |
|
|
investments: { investments, savingsRate, streaks } |
|
|
}) => { |
|
|
}) => { |
|
|
|
|
|
if (this.dividendGroupBy() === this.investmentGroupBy()) { |
|
|
// Expand both timelines to the union of their groups so that the
|
|
|
// Expand both timelines to the union of their groups so that the
|
|
|
// charts share the same axis, independent of whether a dividend or
|
|
|
// charts share the same axis, independent of whether a dividend or
|
|
|
// an investment has been tracked in a given group
|
|
|
// an investment has been tracked in a given group
|
|
|
@ -286,12 +293,16 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
investment: investmentByDate[date]?.investment ?? 0 |
|
|
investment: investmentByDate[date]?.investment ?? 0 |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.dividendsByGroup = dividends; |
|
|
|
|
|
this.investmentsByGroup = investments; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.savingsRatePerMonth = savingsRate; |
|
|
this.savingsRatePerMonth = savingsRate; |
|
|
this.streaks = streaks; |
|
|
this.streaks = streaks; |
|
|
|
|
|
|
|
|
this.unitCurrentStreak = |
|
|
this.unitCurrentStreak = |
|
|
this.mode() === 'year' |
|
|
this.investmentGroupBy() === 'year' |
|
|
? this.streaks?.currentStreak === 1 |
|
|
? this.streaks?.currentStreak === 1 |
|
|
? translate('YEAR') |
|
|
? translate('YEAR') |
|
|
: translate('YEARS') |
|
|
: translate('YEARS') |
|
|
@ -300,7 +311,7 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
: translate('MONTHS'); |
|
|
: translate('MONTHS'); |
|
|
|
|
|
|
|
|
this.unitLongestStreak = |
|
|
this.unitLongestStreak = |
|
|
this.mode() === 'year' |
|
|
this.investmentGroupBy() === 'year' |
|
|
? this.streaks?.longestStreak === 1 |
|
|
? this.streaks?.longestStreak === 1 |
|
|
? translate('YEAR') |
|
|
? translate('YEAR') |
|
|
: translate('YEARS') |
|
|
: translate('YEARS') |
|
|
|