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 { export interface GetColorParams {
backgroundColor: string;
fontColor: string;
}
export interface GetColorConfigParams {
annualizedNetPerformancePercent: number; annualizedNetPerformancePercent: number;
negativeNetPerformancePercentsRange: { max: number; min: number }; negativeNetPerformancePercentsRange: { max: number; min: number };
positiveNetPerformancePercentsRange: { 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 { orderBy } from 'lodash';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { ColorConfig, GetColorConfigParams } from './interfaces/interfaces'; import { GetColorParams } from './interfaces/interfaces';
const { gray, green, red } = require('open-color'); const { gray, green, red } = require('open-color');
@ -81,11 +81,11 @@ export class GfTreemapChartComponent
this.chart?.destroy(); this.chart?.destroy();
} }
private getColorConfig({ private getColor({
annualizedNetPerformancePercent, annualizedNetPerformancePercent,
negativeNetPerformancePercentsRange, negativeNetPerformancePercentsRange,
positiveNetPerformancePercentsRange positiveNetPerformancePercentsRange
}: GetColorConfigParams): ColorConfig { }: GetColorParams) {
if (Math.abs(annualizedNetPerformancePercent) === 0) { if (Math.abs(annualizedNetPerformancePercent) === 0) {
return { return {
backgroundColor: gray[3], backgroundColor: gray[3],
@ -219,7 +219,7 @@ export class GfTreemapChartComponent
annualizedNetPerformancePercent = annualizedNetPerformancePercent =
Math.round(annualizedNetPerformancePercent * 100) / 100; Math.round(annualizedNetPerformancePercent * 100) / 100;
const { backgroundColor } = this.getColorConfig({ const { backgroundColor } = this.getColor({
annualizedNetPerformancePercent, annualizedNetPerformancePercent,
negativeNetPerformancePercentsRange, negativeNetPerformancePercentsRange,
positiveNetPerformancePercentsRange positiveNetPerformancePercentsRange
@ -250,7 +250,7 @@ export class GfTreemapChartComponent
annualizedNetPerformancePercent = annualizedNetPerformancePercent =
Math.round(annualizedNetPerformancePercent * 100) / 100; Math.round(annualizedNetPerformancePercent * 100) / 100;
const { fontColor } = this.getColorConfig({ const { fontColor } = this.getColor({
annualizedNetPerformancePercent, annualizedNetPerformancePercent,
negativeNetPerformancePercentsRange, negativeNetPerformancePercentsRange,
positiveNetPerformancePercentsRange positiveNetPerformancePercentsRange

Loading…
Cancel
Save