|
@ -39,8 +39,7 @@ 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 { isAfter, isValid, min, subDays } from 'date-fns'; |
|
|
import { isAfter } from 'date-fns'; |
|
|
import { first } from 'lodash'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'gf-investment-chart', |
|
|
selector: 'gf-investment-chart', |
|
@ -53,7 +52,6 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy { |
|
|
@Input() benchmarkDataLabel = ''; |
|
|
@Input() benchmarkDataLabel = ''; |
|
|
@Input() colorScheme: ColorScheme; |
|
|
@Input() colorScheme: ColorScheme; |
|
|
@Input() currency: string; |
|
|
@Input() currency: string; |
|
|
@Input() daysInMarket: number; |
|
|
|
|
|
@Input() groupBy: GroupBy; |
|
|
@Input() groupBy: GroupBy; |
|
|
@Input() historicalDataItems: LineChartItem[] = []; |
|
|
@Input() historicalDataItems: LineChartItem[] = []; |
|
|
@Input() isInPercent = false; |
|
|
@Input() isInPercent = false; |
|
@ -154,23 +152,11 @@ 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 = scaleXMin; |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
|
this.savingsRate && |
|
|
this.savingsRate && |
|
@ -253,7 +239,6 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy { |
|
|
grid: { |
|
|
grid: { |
|
|
display: false |
|
|
display: false |
|
|
}, |
|
|
}, |
|
|
min: scaleXMin, |
|
|
|
|
|
type: 'time', |
|
|
type: 'time', |
|
|
time: { |
|
|
time: { |
|
|
tooltipFormat: getDateFormatString(this.locale), |
|
|
tooltipFormat: getDateFormatString(this.locale), |
|
|