Browse Source

Fix phantom UNKNOWN slice caused by floating-point rounding

pull/7156/head
Thomas Kaul 3 weeks ago
parent
commit
7837afb4e1
  1. 5
      libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts

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);
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]) {
chartData[UNKNOWN_KEY].value = chartData[UNKNOWN_KEY].value.plus(
unknownValueInPercentage

Loading…
Cancel
Save