Browse Source

Refactoring

pull/3954/head
Thomas Kaul 10 months ago
parent
commit
3a8e084373
  1. 7
      libs/ui/src/lib/treemap-chart/interfaces/interfaces.ts
  2. 10
      libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

7
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 };

10
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

Loading…
Cancel
Save