From 3a8e0843733d31ea50c15edf705807aef1eeca7a Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:27:56 +0200 Subject: [PATCH] Refactoring --- libs/ui/src/lib/treemap-chart/interfaces/interfaces.ts | 7 +------ .../src/lib/treemap-chart/treemap-chart.component.ts | 10 +++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/libs/ui/src/lib/treemap-chart/interfaces/interfaces.ts b/libs/ui/src/lib/treemap-chart/interfaces/interfaces.ts index 108da438f..bb673ed64 100644 --- a/libs/ui/src/lib/treemap-chart/interfaces/interfaces.ts +++ b/libs/ui/src/lib/treemap-chart/interfaces/interfaces.ts @@ -1,9 +1,4 @@ -export interface ColorConfig { - backgroundColor: string; - fontColor: string; -} - -export interface GetColorConfigParams { +export interface GetColorParams { annualizedNetPerformancePercent: number; negativeNetPerformancePercentsRange: { max: number; min: number }; positiveNetPerformancePercentsRange: { max: number; min: number }; diff --git a/libs/ui/src/lib/treemap-chart/treemap-chart.component.ts b/libs/ui/src/lib/treemap-chart/treemap-chart.component.ts index 4247f04fb..1acc2c925 100644 --- a/libs/ui/src/lib/treemap-chart/treemap-chart.component.ts +++ b/libs/ui/src/lib/treemap-chart/treemap-chart.component.ts @@ -33,7 +33,7 @@ import { differenceInDays, max } from 'date-fns'; import { orderBy } from 'lodash'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; -import { ColorConfig, GetColorConfigParams } from './interfaces/interfaces'; +import { GetColorParams } from './interfaces/interfaces'; const { gray, green, red } = require('open-color'); @@ -81,11 +81,11 @@ export class GfTreemapChartComponent this.chart?.destroy(); } - private getColorConfig({ + private getColor({ annualizedNetPerformancePercent, negativeNetPerformancePercentsRange, positiveNetPerformancePercentsRange - }: GetColorConfigParams): ColorConfig { + }: GetColorParams) { if (Math.abs(annualizedNetPerformancePercent) === 0) { return { backgroundColor: gray[3], @@ -219,7 +219,7 @@ export class GfTreemapChartComponent annualizedNetPerformancePercent = Math.round(annualizedNetPerformancePercent * 100) / 100; - const { backgroundColor } = this.getColorConfig({ + const { backgroundColor } = this.getColor({ annualizedNetPerformancePercent, negativeNetPerformancePercentsRange, positiveNetPerformancePercentsRange @@ -250,7 +250,7 @@ export class GfTreemapChartComponent annualizedNetPerformancePercent = Math.round(annualizedNetPerformancePercent * 100) / 100; - const { fontColor } = this.getColorConfig({ + const { fontColor } = this.getColor({ annualizedNetPerformancePercent, negativeNetPerformancePercentsRange, positiveNetPerformancePercentsRange