Browse Source

Add min / max, customize label

pull/1498/head
Thomas 3 years ago
parent
commit
642840dac7
  1. 10
      apps/client/src/app/components/investment-chart/investment-chart.component.ts
  2. 3
      apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts
  3. 3
      apps/client/src/app/pages/portfolio/analysis/analysis-page.html

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

@ -48,6 +48,7 @@ import { last } from 'lodash';
}) })
export class InvestmentChartComponent implements OnChanges, OnDestroy { export class InvestmentChartComponent implements OnChanges, OnDestroy {
@Input() benchmarkDataItems: InvestmentItem[] = []; @Input() benchmarkDataItems: InvestmentItem[] = [];
@Input() benchmarkDataLabel = '';
@Input() colorScheme: ColorScheme; @Input() colorScheme: ColorScheme;
@Input() currency: string; @Input() currency: string;
@Input() daysInMarket: number; @Input() daysInMarket: number;
@ -153,7 +154,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {
y: this.isInPercent ? investment * 100 : investment y: this.isInPercent ? investment * 100 : investment
}; };
}), }),
label: $localize`Deposit`, label: this.benchmarkDataLabel,
segment: { segment: {
borderColor: (context: unknown) => borderColor: (context: unknown) =>
this.isInFuture( this.isInFuture(
@ -194,6 +195,9 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {
this.chart.options.plugins.tooltip = <unknown>( this.chart.options.plugins.tooltip = <unknown>(
this.getTooltipPluginConfiguration() this.getTooltipPluginConfiguration()
); );
this.chart.options.scales.x.min = this.daysInMarket
? subDays(new Date(), this.daysInMarket).toISOString()
: undefined;
this.chart.update(); this.chart.update();
} else { } else {
this.chart = new Chart(this.chartCanvas.nativeElement, { this.chart = new Chart(this.chartCanvas.nativeElement, {
@ -264,6 +268,10 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {
color: `rgba(${getTextColor(this.colorScheme)}, 0.8)`, color: `rgba(${getTextColor(this.colorScheme)}, 0.8)`,
display: false display: false
}, },
min: this.daysInMarket
? subDays(new Date(), this.daysInMarket).toISOString()
: undefined,
suggestedMax: new Date().toISOString(),
type: 'time', type: 'time',
time: { time: {
tooltipFormat: getDateFormatString(this.locale), tooltipFormat: getDateFormatString(this.locale),

3
apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts

@ -31,9 +31,11 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
public daysInMarket: number; public daysInMarket: number;
public deviceType: string; public deviceType: string;
public dividendsByMonth: InvestmentItem[]; public dividendsByMonth: InvestmentItem[];
public dividendTimelineDataLabel = $localize`Dividend`;
public firstOrderDate: Date; public firstOrderDate: Date;
public hasImpersonationId: boolean; public hasImpersonationId: boolean;
public investments: InvestmentItem[]; public investments: InvestmentItem[];
public investmentTimelineDataLabel = $localize`Deposit`;
public investmentsByMonth: InvestmentItem[]; public investmentsByMonth: InvestmentItem[];
public isLoadingBenchmarkComparator: boolean; public isLoadingBenchmarkComparator: boolean;
public isLoadingInvestmentChart: boolean; public isLoadingInvestmentChart: boolean;
@ -43,6 +45,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
]; ];
public performanceDataItems: HistoricalDataItem[]; public performanceDataItems: HistoricalDataItem[];
public performanceDataItemsInPercentage: HistoricalDataItem[]; public performanceDataItemsInPercentage: HistoricalDataItem[];
public portfolioEvolutionDataLabel = $localize`Deposit`;
public top3: Position[]; public top3: Position[];
public user: User; public user: User;

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

@ -121,6 +121,7 @@
<gf-investment-chart <gf-investment-chart
class="h-100" class="h-100"
[benchmarkDataItems]="investments" [benchmarkDataItems]="investments"
[benchmarkDataLabel]="portfolioEvolutionDataLabel"
[currency]="user?.settings?.baseCurrency" [currency]="user?.settings?.baseCurrency"
[daysInMarket]="daysInMarket" [daysInMarket]="daysInMarket"
[historicalDataItems]="performanceDataItems" [historicalDataItems]="performanceDataItems"
@ -158,6 +159,7 @@
class="h-100" class="h-100"
groupBy="month" groupBy="month"
[benchmarkDataItems]="investmentsByMonth" [benchmarkDataItems]="investmentsByMonth"
[benchmarkDataLabel]="investmentTimelineDataLabel"
[currency]="user?.settings?.baseCurrency" [currency]="user?.settings?.baseCurrency"
[daysInMarket]="daysInMarket" [daysInMarket]="daysInMarket"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView" [isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
@ -194,6 +196,7 @@
class="h-100" class="h-100"
groupBy="month" groupBy="month"
[benchmarkDataItems]="dividendsByMonth" [benchmarkDataItems]="dividendsByMonth"
[benchmarkDataLabel]="dividendTimelineDataLabel"
[currency]="user?.settings?.baseCurrency" [currency]="user?.settings?.baseCurrency"
[daysInMarket]="daysInMarket" [daysInMarket]="daysInMarket"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView" [isInPercent]="hasImpersonationId || user.settings.isRestrictedView"

Loading…
Cancel
Save