Feature/separate deposit and savings in fire calculator (#837)

* Separate deposit and savings

* Update changelog
This commit is contained in:
Thomas Kaul 2022-04-16 21:01:55 +02:00 committed by GitHub
parent 638ae3f7fa
commit 0d8362ca8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 7 deletions

View File

@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support to export a single future activity (draft) as an `.ics` file - Added support to export a single future activity (draft) as an `.ics` file
- Added the _Boringly Getting Rich_ guide to the resources section - Added the _Boringly Getting Rich_ guide to the resources section
### Changed
- Separated the deposit and savings in the chart of the the _FIRE_ calculator
## 1.137.0 - 15.04.2022 ## 1.137.0 - 15.04.2022
### Added ### Added

View File

@ -11,7 +11,7 @@ import {
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import { FormBuilder, FormControl } from '@angular/forms'; import { FormBuilder, FormControl } from '@angular/forms';
import { primaryColorRgb, secondaryColorRgb } from '@ghostfolio/common/config'; import { primaryColorRgb } from '@ghostfolio/common/config';
import { transformTickToAbbreviation } from '@ghostfolio/common/helper'; import { transformTickToAbbreviation } from '@ghostfolio/common/helper';
import { import {
BarController, BarController,
@ -21,6 +21,7 @@ import {
LinearScale, LinearScale,
Tooltip Tooltip
} from 'chart.js'; } from 'chart.js';
import * as Color from 'color';
import { isNumber } from 'lodash'; import { isNumber } from 'lodash';
import { Subject, takeUntil } from 'rxjs'; import { Subject, takeUntil } from 'rxjs';
@ -211,16 +212,30 @@ export class FireCalculatorComponent
labels.push(year); labels.push(year);
} }
const datasetDeposit = {
backgroundColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`,
data: [],
label: 'Deposit'
};
const datasetInterest = { const datasetInterest = {
backgroundColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`, backgroundColor: Color(
`rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`
)
.lighten(0.5)
.hex(),
data: [], data: [],
label: 'Interest' label: 'Interest'
}; };
const datasetPrincipal = { const datasetSavings = {
backgroundColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`, backgroundColor: Color(
`rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`
)
.lighten(0.25)
.hex(),
data: [], data: [],
label: 'Principal' label: 'Savings'
}; };
for (let period = 1; period <= t; period++) { for (let period = 1; period <= t; period++) {
@ -232,8 +247,9 @@ export class FireCalculatorComponent
r r
}); });
datasetPrincipal.data.push(principal.toNumber()); datasetDeposit.data.push(this.fireWealth);
datasetInterest.data.push(interest.toNumber()); datasetInterest.data.push(interest.toNumber());
datasetSavings.data.push(principal.minus(this.fireWealth).toNumber());
if (period === t) { if (period === t) {
this.projectedTotalAmount = totalAmount.toNumber(); this.projectedTotalAmount = totalAmount.toNumber();
@ -242,7 +258,7 @@ export class FireCalculatorComponent
return { return {
labels, labels,
datasets: [datasetPrincipal, datasetInterest] datasets: [datasetDeposit, datasetSavings, datasetInterest]
}; };
} }
} }