Browse Source

Bugfix/phantom UNKNOWN slice in portfolio proportion chart caused by floating point rounding (#7156)

* Fix phantom UNKNOWN slice caused by floating-point rounding

* Update changelog
pull/7160/head
Thomas Kaul 2 days ago
committed by GitHub
parent
commit
8988cbe4e9
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 5
      libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts

1
CHANGELOG.md

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed a phantom `UNKNOWN` slice in the portfolio proportion chart component caused by floating-point rounding
- Fixed the base currency for the total value calculation in the public access for portfolio sharing - Fixed the base currency for the total value calculation in the public access for portfolio sharing
- Fixed an issue in the public access for portfolio sharing that exposed absolute values of the top holdings of ETFs - Fixed an issue in the public access for portfolio sharing that exposed absolute values of the top holdings of ETFs
- Fixed the time zone handling in the `api` test suite for deterministic execution in `UTC` - Fixed the time zone handling in the `api` test suite for deterministic execution in `UTC`

5
libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts

@ -204,8 +204,9 @@ export class GfPortfolioProportionChartComponent
const unknownValueInPercentage = new Big(1).minus(totalValueInPercentage); const unknownValueInPercentage = new Big(1).minus(totalValueInPercentage);
if (unknownValueInPercentage.gt(0)) { // If total is below 100%, allocate the remaining percentage to UNKNOWN_KEY,
// If total is below 100%, allocate the remaining percentage to UNKNOWN_KEY // but ignore negligible remainders to avoid a phantom slice
if (unknownValueInPercentage.gt(0.0001)) {
if (chartData[UNKNOWN_KEY]) { if (chartData[UNKNOWN_KEY]) {
chartData[UNKNOWN_KEY].value = chartData[UNKNOWN_KEY].value.plus( chartData[UNKNOWN_KEY].value = chartData[UNKNOWN_KEY].value.plus(
unknownValueInPercentage unknownValueInPercentage

Loading…
Cancel
Save