Browse Source

Bugfix/negative zero in treemap chart tooltip (#8043)

* Fix negative zero

* Update changelog
pull/8046/head^2
Thomas Kaul 6 days ago
committed by GitHub
parent
commit
3f88ad3783
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 42
      libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

2
CHANGELOG.md

@ -15,12 +15,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Localized the number formatting in the chart of the holdings tab on the home page
- Changed the installation of the dependencies from `npm install` to `npm ci` in the `Dockerfile` - Changed the installation of the dependencies from `npm install` to `npm ci` in the `Dockerfile`
- Upgraded `@simplewebauthn/browser` and `@simplewebauthn/server` from version `13.3` to `14.0` - Upgraded `@simplewebauthn/browser` and `@simplewebauthn/server` from version `13.3` to `14.0`
- Upgraded `nestjs` from version `11.2.3` to `11.2.6` - Upgraded `nestjs` from version `11.2.3` to `11.2.6`
### Fixed ### Fixed
- Fixed an issue with the algebraic sign in the tooltip of the chart of the holdings tab on the home page
- Fixed the asset profile of the activities after a fee, an interest or a liability with the same symbol in the activities import - Fixed the asset profile of the activities after a fee, an interest or a liability with the same symbol in the activities import
### Todo ### Todo

42
libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

@ -314,23 +314,18 @@ export class GfTreemapChartComponent
formatter: (context: GfTreemapScriptableContext) => { formatter: (context: GfTreemapScriptableContext) => {
const raw = context.raw as GfTreemapDataPoint; const raw = context.raw as GfTreemapDataPoint;
let netPerformancePercentWithCurrencyEffect = round(
raw._data.netPerformancePercentWithCurrencyEffect,
4
);
if (Math.abs(netPerformancePercentWithCurrencyEffect) === 0) {
netPerformancePercentWithCurrencyEffect = Math.abs(
netPerformancePercentWithCurrencyEffect
);
}
const name = raw._data.assetProfile.name; const name = raw._data.assetProfile.name;
const symbol = raw._data.assetProfile.symbol; const symbol = raw._data.assetProfile.symbol;
return [ return [
isUUID(symbol) ? (name ?? symbol) : symbol, isUUID(symbol) ? (name ?? symbol) : symbol,
`${netPerformancePercentWithCurrencyEffect > 0 ? '+' : ''}${(netPerformancePercentWithCurrencyEffect * 100).toFixed(2)}%` `${(
raw._data.netPerformancePercentWithCurrencyEffect * 100
).toLocaleString(this.locale(), {
maximumFractionDigits: 2,
minimumFractionDigits: 2,
signDisplay: 'exceptZero'
})}%`
]; ];
}, },
hoverColor: undefined, hoverColor: undefined,
@ -402,13 +397,21 @@ export class GfTreemapChartComponent
label: (context: TooltipItem<'treemap'>) => { label: (context: TooltipItem<'treemap'>) => {
const raw = context.raw as GfTreemapDataPoint; const raw = context.raw as GfTreemapDataPoint;
const allocationInPercentage = `${(raw._data.allocationInPercentage * 100).toFixed(2)}%`; const allocationInPercentage = `${(
raw._data.allocationInPercentage * 100
).toLocaleString(this.locale(), {
maximumFractionDigits: 2,
minimumFractionDigits: 2
})}%`;
const name = getHoldingName(raw._data.assetProfile); const name = getHoldingName(raw._data.assetProfile);
const sign = const netPerformanceInPercentageWithSign = `${(
raw._data.netPerformancePercentWithCurrencyEffect > 0 ? '+' : ''; raw._data.netPerformancePercentWithCurrencyEffect * 100
).toLocaleString(this.locale(), {
const netPerformanceInPercentageWithSign = `${sign}${(raw._data.netPerformancePercentWithCurrencyEffect * 100).toFixed(2)}%`; maximumFractionDigits: 2,
minimumFractionDigits: 2,
signDisplay: 'exceptZero'
})}%`;
if (raw._data.valueInBaseCurrency !== null) { if (raw._data.valueInBaseCurrency !== null) {
const value = raw._data.valueInBaseCurrency; const value = raw._data.valueInBaseCurrency;
@ -421,11 +424,12 @@ export class GfTreemapChartComponent
})} ${this.baseCurrency()}`, })} ${this.baseCurrency()}`,
'', '',
$localize`Change` + ' (' + $localize`Performance` + ')', $localize`Change` + ' (' + $localize`Performance` + ')',
`${sign}${raw._data.netPerformanceWithCurrencyEffect.toLocaleString( `${raw._data.netPerformanceWithCurrencyEffect.toLocaleString(
this.locale(), this.locale(),
{ {
maximumFractionDigits: 2, maximumFractionDigits: 2,
minimumFractionDigits: 2 minimumFractionDigits: 2,
signDisplay: 'exceptZero'
} }
)} ${this.baseCurrency()} (${netPerformanceInPercentageWithSign})` )} ${this.baseCurrency()} (${netPerformanceInPercentageWithSign})`
]; ];

Loading…
Cancel
Save