Browse Source

Merge branch 'main' into bugfix/light-color-scheme-in-chart-helpers

pull/7975/head
Thomas Kaul 2 weeks ago
committed by GitHub
parent
commit
f4b97e72df
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 22
      apps/client/src/app/components/investment-chart/investment-chart.component.ts

22
apps/client/src/app/components/investment-chart/investment-chart.component.ts

@ -7,7 +7,11 @@ import {
getZeroLineAnnotation, getZeroLineAnnotation,
transformTickToAbbreviation transformTickToAbbreviation
} from '@ghostfolio/common/chart-helper'; } from '@ghostfolio/common/chart-helper';
import { primaryColorRgb, secondaryColorRgb } from '@ghostfolio/common/config'; import {
DEFAULT_COLOR_SCHEME,
primaryColorRgb,
secondaryColorRgb
} from '@ghostfolio/common/config';
import { getLocale, parseDate } from '@ghostfolio/common/helper'; import { getLocale, parseDate } 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';
@ -170,13 +174,15 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
this.chart.update(); this.chart.update();
} else { } else {
const colorScheme = this.colorScheme ?? DEFAULT_COLOR_SCHEME;
this.chart = new Chart<'bar' | 'line'>( this.chart = new Chart<'bar' | 'line'>(
this.chartCanvas().nativeElement, this.chartCanvas().nativeElement,
{ {
data: chartData, data: chartData,
options: { options: {
animation: false, animation: false,
elements: getChartElementsOptions(this.colorScheme), elements: getChartElementsOptions(colorScheme),
interaction: { intersect: false, mode: 'index' }, interaction: { intersect: false, mode: 'index' },
maintainAspectRatio: true, maintainAspectRatio: true,
plugins: { plugins: {
@ -204,7 +210,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
value: this.savingsRate value: this.savingsRate
} }
: undefined, : undefined,
yAxis: getZeroLineAnnotation(this.colorScheme) yAxis: getZeroLineAnnotation(colorScheme)
} }
}, },
legend: { legend: {
@ -212,18 +218,18 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
}, },
tooltip: this.getTooltipPluginConfiguration(), tooltip: this.getTooltipPluginConfiguration(),
verticalHoverLine: { verticalHoverLine: {
color: getChartBorderColor(this.colorScheme) color: getChartBorderColor(colorScheme)
} }
}, },
responsive: true, responsive: true,
scales: { scales: {
x: getTimeAxisOptions({ x: getTimeAxisOptions({
colorScheme,
borderWidth: this.groupBy ? 0 : 1, borderWidth: this.groupBy ? 0 : 1,
colorScheme: this.colorScheme,
locale: this.locale locale: this.locale
}), }),
y: getValueAxisOptions({ y: getValueAxisOptions({
colorScheme: this.colorScheme, colorScheme,
display: !this.isInPercentage, display: !this.isInPercentage,
tickCallback: (tickValue) => { tickCallback: (tickValue) => {
return transformTickToAbbreviation(Number(tickValue)); return transformTickToAbbreviation(Number(tickValue));
@ -232,7 +238,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
} }
}, },
plugins: [ plugins: [
getVerticalHoverLinePlugin(this.chartCanvas(), this.colorScheme) getVerticalHoverLinePlugin(this.chartCanvas(), colorScheme)
], ],
type: this.groupBy ? 'bar' : 'line' type: this.groupBy ? 'bar' : 'line'
} }
@ -245,7 +251,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
TooltipOptions<'bar' | 'line'> TooltipOptions<'bar' | 'line'>
> { > {
return getTimeSeriesTooltipOptions<'bar' | 'line'>({ return getTimeSeriesTooltipOptions<'bar' | 'line'>({
colorScheme: this.colorScheme, colorScheme: this.colorScheme ?? DEFAULT_COLOR_SCHEME,
currency: this.isInPercentage ? undefined : this.currency, currency: this.isInPercentage ? undefined : this.currency,
groupBy: this.groupBy, groupBy: this.groupBy,
locale: this.isInPercentage ? undefined : this.locale, locale: this.isInPercentage ? undefined : this.locale,

Loading…
Cancel
Save