Browse Source

Task/harmonize colors in investment chart component (#8105)

* Harmonize colors

* Update changelog
pull/8070/head^2
Thomas Kaul 11 hours ago
committed by GitHub
parent
commit
f22e896c34
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 23
      apps/client/src/app/components/investment-chart/investment-chart.component.ts

1
CHANGELOG.md

@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Harmonized the colors in the investment chart component
- Improved the language localization for Chinese (`zh`) - Improved the language localization for Chinese (`zh`)
## 3.82.0 - 2026-10-09 ## 3.82.0 - 2026-10-09

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

@ -113,10 +113,15 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
} }
private initialize() { private initialize() {
// Create a clone const isBarChart = !!this.groupBy;
const benchmarkColorRgb = isBarChart ? primaryColorRgb : secondaryColorRgb;
// Create clones of the input data
this.investments = this.benchmarkDataItems.map((item) => this.investments = this.benchmarkDataItems.map((item) =>
Object.assign({}, item) Object.assign({}, item)
); );
this.values = this.historicalDataItems.map((item) => this.values = this.historicalDataItems.map((item) =>
Object.assign({}, item) Object.assign({}, item)
); );
@ -127,9 +132,9 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
}), }),
datasets: [ datasets: [
{ {
backgroundColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`, backgroundColor: `rgb(${benchmarkColorRgb.r}, ${benchmarkColorRgb.g}, ${benchmarkColorRgb.b})`,
borderColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`, borderColor: `rgb(${benchmarkColorRgb.r}, ${benchmarkColorRgb.g}, ${benchmarkColorRgb.b})`,
borderWidth: this.groupBy ? 0 : 1, borderWidth: isBarChart ? 0 : 1,
data: this.investments.map(({ date, investment }) => { data: this.investments.map(({ date, investment }) => {
return { return {
x: parseDate(date)?.getTime() ?? null, x: parseDate(date)?.getTime() ?? null,
@ -141,7 +146,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
borderColor: (context) => borderColor: (context) =>
this.isInFuture( this.isInFuture(
context, context,
`rgba(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b}, 0.67)` `rgba(${benchmarkColorRgb.r}, ${benchmarkColorRgb.g}, ${benchmarkColorRgb.b}, 0.67)`
), ),
borderDash: (context) => this.isInFuture(context, [2, 2]) borderDash: (context) => this.isInFuture(context, [2, 2])
}, },
@ -200,10 +205,10 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
annotations: { annotations: {
savingsRate: this.savingsRate savingsRate: this.savingsRate
? { ? {
borderColor: `rgba(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b}, 0.75)`, borderColor: `rgba(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b}, 0.75)`,
borderWidth: 1, borderWidth: 1,
label: { label: {
backgroundColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`, backgroundColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`,
borderRadius: 2, borderRadius: 2,
color: 'white', color: 'white',
content: $localize`Savings Rate`, content: $localize`Savings Rate`,
@ -234,7 +239,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
responsive: true, responsive: true,
scales: { scales: {
x: getTimeAxisOptions({ x: getTimeAxisOptions({
borderWidth: this.groupBy ? 0 : 1, borderWidth: isBarChart ? 0 : 1,
colorScheme: this.colorScheme, colorScheme: this.colorScheme,
locale: this.locale locale: this.locale
}), }),
@ -250,7 +255,7 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
plugins: [ plugins: [
getVerticalHoverLinePlugin(this.chartCanvas(), this.colorScheme) getVerticalHoverLinePlugin(this.chartCanvas(), this.colorScheme)
], ],
type: this.groupBy ? 'bar' : 'line' type: isBarChart ? 'bar' : 'line'
} }
); );
} }

Loading…
Cancel
Save