From 8f923d04861c91606b0a87cefa178607dea36a38 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 30 Sep 2025 20:23:58 +0200 Subject: [PATCH] Feature/improve number formatting of y-axis in investment chart component (#5633) * Improve number formatting of y-axis * Update changelog --- CHANGELOG.md | 1 + libs/common/src/lib/chart-helper.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e94d88d01..7593b5e2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Improved the number formatting of the y-axis labels in the investment chart component - Localized the number formatting of the y-axis labels in the line chart component - Improved the wording of the 4% rule in the _FIRE_ section - Improved the language localization for German (`de`) diff --git a/libs/common/src/lib/chart-helper.ts b/libs/common/src/lib/chart-helper.ts index 4181ebbbf..697f39467 100644 --- a/libs/common/src/lib/chart-helper.ts +++ b/libs/common/src/lib/chart-helper.ts @@ -132,8 +132,10 @@ export function getVerticalHoverLinePlugin( } export function transformTickToAbbreviation(value: number) { - if (value >= -999 && value <= 999) { - return value.toString(); + if (value === 0) { + return '0'; + } else if (value >= -999 && value <= 999) { + return value.toFixed(2); } else if (value >= -999999 && value <= 999999) { return `${value / 1000}K`; } else {