Browse Source

Task/refactor input in investment chart component (#6693)

* Refactor input to isInPercentage
pull/6695/head
Thomas Kaul 1 week ago
committed by GitHub
parent
commit
71ffd045cf
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html
  2. 14
      apps/client/src/app/components/investment-chart/investment-chart.component.ts
  3. 12
      apps/client/src/app/pages/portfolio/analysis/analysis-page.html

2
apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html

@ -24,7 +24,7 @@
class="h-100" class="h-100"
[currency]="user?.settings?.baseCurrency" [currency]="user?.settings?.baseCurrency"
[historicalDataItems]="historicalDataItems" [historicalDataItems]="historicalDataItems"
[isInPercent]=" [isInPercentage]="
data.hasImpersonationId || user.settings.isRestrictedView data.hasImpersonationId || user.settings.isRestrictedView
" "
[isLoading]="isLoadingChart" [isLoading]="isLoadingChart"

14
apps/client/src/app/components/investment-chart/investment-chart.component.ts

@ -61,7 +61,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
@Input() currency: string; @Input() currency: string;
@Input() groupBy: GroupBy; @Input() groupBy: GroupBy;
@Input() historicalDataItems: LineChartItem[] = []; @Input() historicalDataItems: LineChartItem[] = [];
@Input() isInPercent = false; @Input() isInPercentage = false;
@Input() isLoading = false; @Input() isLoading = false;
@Input() locale = getLocale(); @Input() locale = getLocale();
@Input() savingsRate = 0; @Input() savingsRate = 0;
@ -119,7 +119,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
data: this.investments.map(({ date, investment }) => { data: this.investments.map(({ date, investment }) => {
return { return {
x: parseDate(date).getTime(), x: parseDate(date).getTime(),
y: this.isInPercent ? investment * 100 : investment y: this.isInPercentage ? investment * 100 : investment
}; };
}), }),
label: this.benchmarkDataLabel, label: this.benchmarkDataLabel,
@ -139,7 +139,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
data: this.values.map(({ date, value }) => { data: this.values.map(({ date, value }) => {
return { return {
x: parseDate(date).getTime(), x: parseDate(date).getTime(),
y: this.isInPercent ? value * 100 : value y: this.isInPercentage ? value * 100 : value
}; };
}), }),
fill: false, fill: false,
@ -251,7 +251,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
border: { border: {
display: false display: false
}, },
display: !this.isInPercent, display: !this.isInPercentage,
grid: { grid: {
color: ({ scale, tick }) => { color: ({ scale, tick }) => {
if ( if (
@ -292,10 +292,10 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
return { return {
...getTooltipOptions({ ...getTooltipOptions({
colorScheme: this.colorScheme, colorScheme: this.colorScheme,
currency: this.isInPercent ? undefined : this.currency, currency: this.isInPercentage ? undefined : this.currency,
groupBy: this.groupBy, groupBy: this.groupBy,
locale: this.isInPercent ? undefined : this.locale, locale: this.isInPercentage ? undefined : this.locale,
unit: this.isInPercent ? '%' : undefined unit: this.isInPercentage ? '%' : undefined
}), }),
mode: 'index', mode: 'index',
position: 'top', position: 'top',

12
apps/client/src/app/pages/portfolio/analysis/analysis-page.html

@ -417,7 +417,9 @@
[benchmarkDataLabel]="portfolioEvolutionDataLabel" [benchmarkDataLabel]="portfolioEvolutionDataLabel"
[currency]="user?.settings?.baseCurrency" [currency]="user?.settings?.baseCurrency"
[historicalDataItems]="performanceDataItems" [historicalDataItems]="performanceDataItems"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView" [isInPercentage]="
hasImpersonationId || user.settings.isRestrictedView
"
[isLoading]="isLoadingInvestmentChart" [isLoading]="isLoadingInvestmentChart"
[locale]="user?.settings?.locale" [locale]="user?.settings?.locale"
/> />
@ -473,7 +475,9 @@
[benchmarkDataLabel]="investmentTimelineDataLabel" [benchmarkDataLabel]="investmentTimelineDataLabel"
[currency]="user?.settings?.baseCurrency" [currency]="user?.settings?.baseCurrency"
[groupBy]="mode" [groupBy]="mode"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView" [isInPercentage]="
hasImpersonationId || user.settings.isRestrictedView
"
[isLoading]="isLoadingInvestmentTimelineChart" [isLoading]="isLoadingInvestmentTimelineChart"
[locale]="user?.settings?.locale" [locale]="user?.settings?.locale"
[savingsRate]="savingsRate" [savingsRate]="savingsRate"
@ -508,7 +512,9 @@
[benchmarkDataLabel]="dividendTimelineDataLabel" [benchmarkDataLabel]="dividendTimelineDataLabel"
[currency]="user?.settings?.baseCurrency" [currency]="user?.settings?.baseCurrency"
[groupBy]="mode" [groupBy]="mode"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView" [isInPercentage]="
hasImpersonationId || user.settings.isRestrictedView
"
[isLoading]="isLoadingDividendTimelineChart" [isLoading]="isLoadingDividendTimelineChart"
[locale]="user?.settings?.locale" [locale]="user?.settings?.locale"
/> />

Loading…
Cancel
Save