Browse Source

Feature/Improve background color assignment in treemap chart component (#3918)

* Improve background color assignment in treemap chart component

* Update changelog
pull/3895/head^2
Madhab Chandra Sahoo 4 months ago
committed by GitHub
parent
commit
67a147bd96
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 13
      libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

1
CHANGELOG.md

@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Improved the backgrounds of the chart of the holdings tab on the home page (experimental)
- Improved the labels of the chart of the holdings tab on the home page (experimental) - Improved the labels of the chart of the holdings tab on the home page (experimental)
- Refactored the rule thresholds in the _X-ray_ section (experimental) - Refactored the rule thresholds in the _X-ray_ section (experimental)
- Exposed the timeout of the portfolio snapshot computation as an environment variable (`PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT`) - Exposed the timeout of the portfolio snapshot computation as an environment variable (`PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT`)

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

@ -91,7 +91,7 @@ export class GfTreemapChartComponent
datasets: [ datasets: [
{ {
backgroundColor(ctx) { backgroundColor(ctx) {
const annualizedNetPerformancePercentWithCurrencyEffect = let annualizedNetPerformancePercentWithCurrencyEffect =
getAnnualizedPerformancePercent({ getAnnualizedPerformancePercent({
daysInMarket: differenceInDays( daysInMarket: differenceInDays(
endDate, endDate,
@ -105,6 +105,12 @@ export class GfTreemapChartComponent
) )
}).toNumber(); }).toNumber();
// Round to 2 decimal places
annualizedNetPerformancePercentWithCurrencyEffect =
Math.round(
annualizedNetPerformancePercentWithCurrencyEffect * 100
) / 100;
if ( if (
annualizedNetPerformancePercentWithCurrencyEffect > annualizedNetPerformancePercentWithCurrencyEffect >
0.03 * GfTreemapChartComponent.HEAT_MULTIPLIER 0.03 * GfTreemapChartComponent.HEAT_MULTIPLIER
@ -123,8 +129,11 @@ export class GfTreemapChartComponent
} else if (annualizedNetPerformancePercentWithCurrencyEffect > 0) { } else if (annualizedNetPerformancePercentWithCurrencyEffect > 0) {
return green[3]; return green[3];
} else if ( } else if (
annualizedNetPerformancePercentWithCurrencyEffect === 0 Math.abs(annualizedNetPerformancePercentWithCurrencyEffect) === 0
) { ) {
annualizedNetPerformancePercentWithCurrencyEffect = Math.abs(
annualizedNetPerformancePercentWithCurrencyEffect
);
return gray[3]; return gray[3];
} else if ( } else if (
annualizedNetPerformancePercentWithCurrencyEffect > annualizedNetPerformancePercentWithCurrencyEffect >

Loading…
Cancel
Save