|
@ -11,7 +11,8 @@ import { |
|
|
import { |
|
|
import { |
|
|
getTooltipOptions, |
|
|
getTooltipOptions, |
|
|
getTooltipPositionerMapTop, |
|
|
getTooltipPositionerMapTop, |
|
|
getVerticalHoverLinePlugin |
|
|
getVerticalHoverLinePlugin, |
|
|
|
|
|
transformTickToAbbreviation |
|
|
} from '@ghostfolio/common/chart-helper'; |
|
|
} from '@ghostfolio/common/chart-helper'; |
|
|
import { primaryColorRgb, secondaryColorRgb } from '@ghostfolio/common/config'; |
|
|
import { primaryColorRgb, secondaryColorRgb } from '@ghostfolio/common/config'; |
|
|
import { |
|
|
import { |
|
@ -19,8 +20,7 @@ import { |
|
|
getBackgroundColor, |
|
|
getBackgroundColor, |
|
|
getDateFormatString, |
|
|
getDateFormatString, |
|
|
getTextColor, |
|
|
getTextColor, |
|
|
parseDate, |
|
|
parseDate |
|
|
transformTickToAbbreviation |
|
|
|
|
|
} from '@ghostfolio/common/helper'; |
|
|
} from '@ghostfolio/common/helper'; |
|
|
import { LineChartItem } from '@ghostfolio/common/interfaces'; |
|
|
import { LineChartItem } from '@ghostfolio/common/interfaces'; |
|
|
import { InvestmentItem } from '@ghostfolio/common/interfaces/investment-item.interface'; |
|
|
import { InvestmentItem } from '@ghostfolio/common/interfaces/investment-item.interface'; |
|
@ -136,10 +136,13 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy { |
|
|
date, |
|
|
date, |
|
|
investment: last(this.investments).investment |
|
|
investment: last(this.investments).investment |
|
|
}); |
|
|
}); |
|
|
this.values.push({ date, value: last(this.values).value }); |
|
|
this.values.push({ |
|
|
|
|
|
date, |
|
|
|
|
|
value: last(this.values).value |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const data = { |
|
|
const chartData = { |
|
|
labels: this.historicalDataItems.map(({ date }) => { |
|
|
labels: this.historicalDataItems.map(({ date }) => { |
|
|
return parseDate(date); |
|
|
return parseDate(date); |
|
|
}), |
|
|
}), |
|
@ -191,7 +194,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy { |
|
|
|
|
|
|
|
|
if (this.chartCanvas) { |
|
|
if (this.chartCanvas) { |
|
|
if (this.chart) { |
|
|
if (this.chart) { |
|
|
this.chart.data = data; |
|
|
this.chart.data = chartData; |
|
|
this.chart.options.plugins.tooltip = <unknown>( |
|
|
this.chart.options.plugins.tooltip = <unknown>( |
|
|
this.getTooltipPluginConfiguration() |
|
|
this.getTooltipPluginConfiguration() |
|
|
); |
|
|
); |
|
@ -213,7 +216,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy { |
|
|
this.chart.update(); |
|
|
this.chart.update(); |
|
|
} else { |
|
|
} else { |
|
|
this.chart = new Chart(this.chartCanvas.nativeElement, { |
|
|
this.chart = new Chart(this.chartCanvas.nativeElement, { |
|
|
data, |
|
|
data: chartData, |
|
|
options: { |
|
|
options: { |
|
|
animation: false, |
|
|
animation: false, |
|
|
elements: { |
|
|
elements: { |
|
@ -328,6 +331,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy { |
|
|
...getTooltipOptions({ |
|
|
...getTooltipOptions({ |
|
|
colorScheme: this.colorScheme, |
|
|
colorScheme: this.colorScheme, |
|
|
currency: this.isInPercent ? undefined : this.currency, |
|
|
currency: this.isInPercent ? undefined : this.currency, |
|
|
|
|
|
groupBy: this.groupBy, |
|
|
locale: this.isInPercent ? undefined : this.locale, |
|
|
locale: this.isInPercent ? undefined : this.locale, |
|
|
unit: this.isInPercent ? '%' : undefined |
|
|
unit: this.isInPercent ? '%' : undefined |
|
|
}), |
|
|
}), |
|
|