From 36298b217e42e453f58c81a6c2c91006bb9c418f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 7 Apr 2023 17:09:34 +0200 Subject: [PATCH] Feature/improve tick abbreviation function (#1828) * Keep the value if value smaller than 1000 * Update changelog --- CHANGELOG.md | 1 + libs/common/src/lib/chart-helper.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee8f99f57..6873d9c67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improved the activities import for `csv` files exported by _Interactive Brokers_ +- Improved the rendering of the chart ticks (`0.5K` → `500`) - Increased the historical market data gathering of currency pairs to 10+ years - Improved the content of the Frequently Asked Questions (FAQ) page - Improved the content of the pricing page diff --git a/libs/common/src/lib/chart-helper.ts b/libs/common/src/lib/chart-helper.ts index 1befb1585..d4a5d75d9 100644 --- a/libs/common/src/lib/chart-helper.ts +++ b/libs/common/src/lib/chart-helper.ts @@ -131,5 +131,11 @@ export function getVerticalHoverLinePlugin( } export function transformTickToAbbreviation(value: number) { - return value < 1000000 ? `${value / 1000}K` : `${value / 1000000}M`; + if (value >= -999 && value <= 999) { + return value.toString(); + } else if (value >= -999999 && value <= 999999) { + return `${value / 1000}K`; + } else { + return `${value / 1000000}M`; + } }