From f418358bf1b035a1f9cc2cb2ed297d0c417eeed1 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 30 Sep 2026 14:46:35 +0200 Subject: [PATCH] Remove default color scheme fallback --- .../investment-chart.component.ts | 22 +++++++------------ libs/common/src/lib/config.ts | 3 +-- libs/common/src/lib/helper.spec.ts | 2 ++ libs/common/src/lib/helper.ts | 2 +- .../treemap-chart.component.stories.ts | 4 +--- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/apps/client/src/app/components/investment-chart/investment-chart.component.ts b/apps/client/src/app/components/investment-chart/investment-chart.component.ts index f51fc4d641..b3cc0d753e 100644 --- a/apps/client/src/app/components/investment-chart/investment-chart.component.ts +++ b/apps/client/src/app/components/investment-chart/investment-chart.component.ts @@ -7,11 +7,7 @@ import { getZeroLineAnnotation, transformTickToAbbreviation } from '@ghostfolio/common/chart-helper'; -import { - DEFAULT_COLOR_SCHEME, - primaryColorRgb, - secondaryColorRgb -} from '@ghostfolio/common/config'; +import { primaryColorRgb, secondaryColorRgb } from '@ghostfolio/common/config'; import { getLocale, parseDate } from '@ghostfolio/common/helper'; import { LineChartItem } from '@ghostfolio/common/interfaces'; import { InvestmentItem } from '@ghostfolio/common/interfaces/investment-item.interface'; @@ -174,15 +170,13 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy { this.chart.update(); } else { - const colorScheme = this.colorScheme ?? DEFAULT_COLOR_SCHEME; - this.chart = new Chart<'bar' | 'line'>( this.chartCanvas().nativeElement, { data: chartData, options: { animation: false, - elements: getChartElementsOptions(colorScheme), + elements: getChartElementsOptions(this.colorScheme), interaction: { intersect: false, mode: 'index' }, maintainAspectRatio: true, plugins: { @@ -210,7 +204,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy { value: this.savingsRate } : undefined, - yAxis: getZeroLineAnnotation(colorScheme) + yAxis: getZeroLineAnnotation(this.colorScheme) } }, legend: { @@ -218,18 +212,18 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy { }, tooltip: this.getTooltipPluginConfiguration(), verticalHoverLine: { - color: getChartBorderColor(colorScheme) + color: getChartBorderColor(this.colorScheme) } }, responsive: true, scales: { x: getTimeAxisOptions({ - colorScheme, borderWidth: this.groupBy ? 0 : 1, + colorScheme: this.colorScheme, locale: this.locale }), y: getValueAxisOptions({ - colorScheme, + colorScheme: this.colorScheme, display: !this.isInPercentage, tickCallback: (tickValue) => { return transformTickToAbbreviation(Number(tickValue)); @@ -238,7 +232,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy { } }, plugins: [ - getVerticalHoverLinePlugin(this.chartCanvas(), colorScheme) + getVerticalHoverLinePlugin(this.chartCanvas(), this.colorScheme) ], type: this.groupBy ? 'bar' : 'line' } @@ -251,7 +245,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy { TooltipOptions<'bar' | 'line'> > { return getTimeSeriesTooltipOptions<'bar' | 'line'>({ - colorScheme: this.colorScheme ?? DEFAULT_COLOR_SCHEME, + colorScheme: this.colorScheme, currency: this.isInPercentage ? undefined : this.currency, groupBy: this.groupBy, locale: this.isInPercentage ? undefined : this.locale, diff --git a/libs/common/src/lib/config.ts b/libs/common/src/lib/config.ts index 03d36f577b..6ff492f671 100644 --- a/libs/common/src/lib/config.ts +++ b/libs/common/src/lib/config.ts @@ -8,7 +8,7 @@ import { import { JobOptions, JobStatus } from 'bull'; import ms from 'ms'; -import { ColorScheme, DateRange } from './types'; +import { DateRange } from './types'; export const ghostfolioPrefix = 'GF'; @@ -100,7 +100,6 @@ export const PORTFOLIO_SNAPSHOT_COMPUTATION_QUEUE_PRIORITY_LOW = export const STATISTICS_GATHERING_QUEUE = 'STATISTICS_GATHERING_QUEUE'; -export const DEFAULT_COLOR_SCHEME: ColorScheme = 'LIGHT'; export const DEFAULT_CURRENCY = 'USD'; export const DEFAULT_DATE_FORMAT_MONTH_YEAR = 'MMM yyyy'; export const DEFAULT_DATE_RANGE: DateRange = 'max'; diff --git a/libs/common/src/lib/helper.spec.ts b/libs/common/src/lib/helper.spec.ts index f7c9d7a41f..b7e7635670 100644 --- a/libs/common/src/lib/helper.spec.ts +++ b/libs/common/src/lib/helper.spec.ts @@ -373,11 +373,13 @@ describe('Helper', () => { it('Auto color scheme with operating system in dark mode', () => { mockPrefersColorSchemeDark(true); expect(isDarkColorScheme()).toEqual(true); + expect(isDarkColorScheme(null)).toEqual(true); }); it('Auto color scheme with operating system in light mode', () => { mockPrefersColorSchemeDark(false); expect(isDarkColorScheme()).toEqual(false); + expect(isDarkColorScheme(null)).toEqual(false); }); }); diff --git a/libs/common/src/lib/helper.ts b/libs/common/src/lib/helper.ts index fcf330172d..2a76261dae 100644 --- a/libs/common/src/lib/helper.ts +++ b/libs/common/src/lib/helper.ts @@ -608,7 +608,7 @@ export function isCurrencySymbol(aSymbol: string) { ); } -export function isDarkColorScheme(aColorScheme?: ColorScheme) { +export function isDarkColorScheme(aColorScheme?: ColorScheme | null) { if (aColorScheme) { return aColorScheme === 'DARK'; } diff --git a/libs/ui/src/lib/treemap-chart/treemap-chart.component.stories.ts b/libs/ui/src/lib/treemap-chart/treemap-chart.component.stories.ts index 04ea5c65f0..72f34e8027 100644 --- a/libs/ui/src/lib/treemap-chart/treemap-chart.component.stories.ts +++ b/libs/ui/src/lib/treemap-chart/treemap-chart.component.stories.ts @@ -1,5 +1,3 @@ -import { DEFAULT_COLOR_SCHEME } from '@ghostfolio/common/config'; - import { CommonModule } from '@angular/common'; import { moduleMetadata } from '@storybook/angular'; import type { Meta, StoryObj } from '@storybook/angular'; @@ -38,7 +36,7 @@ export const Default: Story = { args: { holdings, baseCurrency: 'USD', - colorScheme: DEFAULT_COLOR_SCHEME, + colorScheme: 'LIGHT', cursor: undefined, dateRange: 'mtd', locale: 'en-US'