|
|
@ -38,6 +38,8 @@ import { |
|
|
BarElement, |
|
|
BarElement, |
|
|
CategoryScale, |
|
|
CategoryScale, |
|
|
Chart, |
|
|
Chart, |
|
|
|
|
|
type ChartData, |
|
|
|
|
|
type ChartDataset, |
|
|
LinearScale, |
|
|
LinearScale, |
|
|
Tooltip |
|
|
Tooltip |
|
|
} from 'chart.js'; |
|
|
} from 'chart.js'; |
|
|
@ -270,7 +272,7 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy { |
|
|
|
|
|
|
|
|
this.chart.update(); |
|
|
this.chart.update(); |
|
|
} else { |
|
|
} else { |
|
|
this.chart = new Chart(this.chartCanvas.nativeElement, { |
|
|
this.chart = new Chart<'bar'>(this.chartCanvas.nativeElement, { |
|
|
data: chartData, |
|
|
data: chartData, |
|
|
options: { |
|
|
options: { |
|
|
plugins: { |
|
|
plugins: { |
|
|
@ -280,7 +282,7 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy { |
|
|
callbacks: { |
|
|
callbacks: { |
|
|
footer: (items) => { |
|
|
footer: (items) => { |
|
|
const totalAmount = items.reduce( |
|
|
const totalAmount = items.reduce( |
|
|
(a, b) => a + b.parsed.y, |
|
|
(a, b) => a + (b.parsed.y ?? 0), |
|
|
0 |
|
|
0 |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
@ -302,8 +304,6 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy { |
|
|
if (context.parsed.y !== null) { |
|
|
if (context.parsed.y !== null) { |
|
|
label += new Intl.NumberFormat(this.locale, { |
|
|
label += new Intl.NumberFormat(this.locale, { |
|
|
currency: this.currency, |
|
|
currency: this.currency, |
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
|
|
// @ts-ignore: Only supported from ES2020 or later
|
|
|
|
|
|
currencyDisplay: 'code', |
|
|
currencyDisplay: 'code', |
|
|
style: 'currency' |
|
|
style: 'currency' |
|
|
}).format(context.parsed.y); |
|
|
}).format(context.parsed.y); |
|
|
@ -345,9 +345,9 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy { |
|
|
this.isLoading = false; |
|
|
this.isLoading = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getChartData() { |
|
|
private getChartData(): ChartData<'bar'> { |
|
|
const currentYear = new Date().getFullYear(); |
|
|
const currentYear = new Date().getFullYear(); |
|
|
const labels = []; |
|
|
const labels: number[] = []; |
|
|
|
|
|
|
|
|
// Principal investment amount
|
|
|
// Principal investment amount
|
|
|
const P: number = this.getP(); |
|
|
const P: number = this.getP(); |
|
|
@ -371,13 +371,13 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy { |
|
|
labels.push(year); |
|
|
labels.push(year); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const datasetDeposit = { |
|
|
const datasetDeposit: ChartDataset<'bar'> = { |
|
|
backgroundColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`, |
|
|
backgroundColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`, |
|
|
data: [], |
|
|
data: [], |
|
|
label: $localize`Deposit` |
|
|
label: $localize`Deposit` |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const datasetInterest = { |
|
|
const datasetInterest: ChartDataset<'bar'> = { |
|
|
backgroundColor: Color( |
|
|
backgroundColor: Color( |
|
|
`rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})` |
|
|
`rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})` |
|
|
) |
|
|
) |
|
|
@ -387,7 +387,7 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy { |
|
|
label: $localize`Interest` |
|
|
label: $localize`Interest` |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const datasetSavings = { |
|
|
const datasetSavings: ChartDataset<'bar'> = { |
|
|
backgroundColor: Color( |
|
|
backgroundColor: Color( |
|
|
`rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})` |
|
|
`rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})` |
|
|
) |
|
|
) |
|
|
|