Bugfix/improve x axis scale of dividend and investment timeline (#3010)
* Improve X-axis scale * Update changelog
This commit is contained in:
parent
cac73ac111
commit
29cb83d469
@ -17,6 +17,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Divided the content of the Frequently Asked Questions (FAQ) page into three sections: _General_, _Cloud (SaaS)_ and _Self-Hosting_
|
- Divided the content of the Frequently Asked Questions (FAQ) page into three sections: _General_, _Cloud (SaaS)_ and _Self-Hosting_
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue with the X-axis scale of the dividend timeline on the analysis page
|
||||||
|
- Fixed an issue with the X-axis scale of the investment timeline on the analysis page
|
||||||
|
|
||||||
## 2.51.0 - 2024-02-12
|
## 2.51.0 - 2024-02-12
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -38,8 +38,16 @@ import {
|
|||||||
} from 'chart.js';
|
} from 'chart.js';
|
||||||
import 'chartjs-adapter-date-fns';
|
import 'chartjs-adapter-date-fns';
|
||||||
import annotationPlugin from 'chartjs-plugin-annotation';
|
import annotationPlugin from 'chartjs-plugin-annotation';
|
||||||
import { addDays, format, isAfter, parseISO, subDays } from 'date-fns';
|
import {
|
||||||
import { last } from 'lodash';
|
addDays,
|
||||||
|
format,
|
||||||
|
isAfter,
|
||||||
|
isValid,
|
||||||
|
min,
|
||||||
|
parseISO,
|
||||||
|
subDays
|
||||||
|
} from 'date-fns';
|
||||||
|
import { first, last } from 'lodash';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-investment-chart',
|
selector: 'gf-investment-chart',
|
||||||
@ -143,7 +151,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const chartData: ChartData<'line'> = {
|
const chartData: ChartData<'bar' | 'line'> = {
|
||||||
labels: this.historicalDataItems.map(({ date }) => {
|
labels: this.historicalDataItems.map(({ date }) => {
|
||||||
return parseDate(date);
|
return parseDate(date);
|
||||||
}),
|
}),
|
||||||
@ -194,17 +202,23 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (this.chartCanvas) {
|
if (this.chartCanvas) {
|
||||||
|
let scaleXMin: string;
|
||||||
|
|
||||||
|
if (this.daysInMarket) {
|
||||||
|
const minDate = min([
|
||||||
|
parseDate(first(this.investments)?.date),
|
||||||
|
subDays(new Date().setHours(0, 0, 0, 0), this.daysInMarket)
|
||||||
|
]);
|
||||||
|
|
||||||
|
scaleXMin = isValid(minDate) ? minDate.toISOString() : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.chart) {
|
if (this.chart) {
|
||||||
this.chart.data = chartData;
|
this.chart.data = chartData;
|
||||||
this.chart.options.plugins.tooltip = <unknown>(
|
this.chart.options.plugins.tooltip = <unknown>(
|
||||||
this.getTooltipPluginConfiguration()
|
this.getTooltipPluginConfiguration()
|
||||||
);
|
);
|
||||||
this.chart.options.scales.x.min = this.daysInMarket
|
this.chart.options.scales.x.min = scaleXMin;
|
||||||
? subDays(
|
|
||||||
new Date().setHours(0, 0, 0, 0),
|
|
||||||
this.daysInMarket
|
|
||||||
).toISOString()
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.savingsRate &&
|
this.savingsRate &&
|
||||||
@ -287,9 +301,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {
|
|||||||
grid: {
|
grid: {
|
||||||
display: false
|
display: false
|
||||||
},
|
},
|
||||||
min: this.daysInMarket
|
min: scaleXMin,
|
||||||
? subDays(new Date(), this.daysInMarket).toISOString()
|
|
||||||
: undefined,
|
|
||||||
suggestedMax: new Date().toISOString(),
|
suggestedMax: new Date().toISOString(),
|
||||||
type: 'time',
|
type: 'time',
|
||||||
time: {
|
time: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user