Browse Source

fix(client): resolve errors

pull/6859/head
KenTandrian 1 day ago
parent
commit
dc5ac1ed00
  1. 18
      apps/client/src/app/components/investment-chart/investment-chart.component.ts

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

@ -118,7 +118,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
borderWidth: this.groupBy ? 0 : 1, borderWidth: this.groupBy ? 0 : 1,
data: this.investments.map(({ date, investment }) => { data: this.investments.map(({ date, investment }) => {
return { return {
x: parseDate(date).getTime(), x: parseDate(date)?.getTime() ?? null,
y: this.isInPercentage ? investment * 100 : investment y: this.isInPercentage ? investment * 100 : investment
}; };
}), }),
@ -138,7 +138,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
borderWidth: 2, borderWidth: 2,
data: this.values.map(({ date, value }) => { data: this.values.map(({ date, value }) => {
return { return {
x: parseDate(date).getTime(), x: parseDate(date)?.getTime() ?? null,
y: this.isInPercentage ? value * 100 : value y: this.isInPercentage ? value * 100 : value
}; };
}), }),
@ -165,14 +165,14 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
this.getTooltipPluginConfiguration(); this.getTooltipPluginConfiguration();
const annotations = this.chart.options.plugins.annotation const annotations = this.chart.options.plugins.annotation
.annotations as Record<string, AnnotationOptions<'line'>>; ?.annotations as Record<string, AnnotationOptions<'line'>>;
if (this.savingsRate && annotations.savingsRate) { if (this.savingsRate && annotations.savingsRate) {
annotations.savingsRate.value = this.savingsRate; annotations.savingsRate.value = this.savingsRate;
} }
this.chart.update(); this.chart.update();
} else { } else {
this.chart = new Chart(this.chartCanvas.nativeElement, { this.chart = new Chart<'bar' | 'line'>(this.chartCanvas.nativeElement, {
data: chartData, data: chartData,
options: { options: {
animation: false, animation: false,
@ -305,8 +305,12 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
} }
private isInFuture<T>(aContext: ScriptableLineSegmentContext, aValue: T) { private isInFuture<T>(aContext: ScriptableLineSegmentContext, aValue: T) {
return isAfter(new Date(aContext?.p1?.parsed?.x), new Date()) const xValue = aContext?.p1?.parsed?.x;
? aValue
: undefined; if (xValue == null) {
return undefined;
}
return isAfter(new Date(xValue), new Date()) ? aValue : undefined;
} }
} }

Loading…
Cancel
Save