Browse Source

resolve comments

pull/7954/head
KenTandrian 1 day ago
parent
commit
f25de494a6
  1. 19
      libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts

19
libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts

@ -60,14 +60,14 @@ const {
export class GfPortfolioProportionChartComponent export class GfPortfolioProportionChartComponent
implements AfterViewInit, OnChanges, OnDestroy implements AfterViewInit, OnChanges, OnDestroy
{ {
@Input() baseCurrency?: string = ''; @Input() baseCurrency?: string;
@Input() colorScheme?: ColorScheme = DEFAULT_COLOR_SCHEME; @Input() colorScheme?: ColorScheme;
@Input() cursor: string; @Input() cursor: string;
@Input() data: { @Input() data: {
[symbol: string]: Pick<PortfolioPosition, 'type'> & { [symbol: string]: Pick<PortfolioPosition, 'type'> & {
dataSource?: DataSource; dataSource?: DataSource;
isClickable?: boolean; isClickable?: boolean;
name: string; name?: string | null;
value: number; value: number;
}; };
} = {}; } = {};
@ -122,10 +122,11 @@ export class GfPortfolioProportionChartComponent
value: Big; value: Big;
}; };
} = {}; } = {};
const textColor = getTextColor(this.colorScheme ?? DEFAULT_COLOR_SCHEME);
this.colorMap = { this.colorMap = {
[this.OTHER_KEY]: [this.OTHER_KEY]: `rgba(${textColor}, 0.24)`,
`rgba(${getTextColor(this.colorScheme ?? DEFAULT_COLOR_SCHEME)}, 0.24)`, [UNKNOWN_KEY]: `rgba(${textColor}, 0.12)`
[UNKNOWN_KEY]: `rgba(${getTextColor(this.colorScheme ?? DEFAULT_COLOR_SCHEME)}, 0.12)`
}; };
if (this.keys.length > 0) { if (this.keys.length > 0) {
@ -179,7 +180,7 @@ export class GfPortfolioProportionChartComponent
); );
} else { } else {
chartData[UNKNOWN_KEY] = { chartData[UNKNOWN_KEY] = {
name: this.data[symbol].name, name: this.data[symbol].name ?? '',
subCategory: secondaryKey subCategory: secondaryKey
? { [secondaryKey]: { value: new Big(0) } } ? { [secondaryKey]: { value: new Big(0) } }
: undefined, : undefined,
@ -191,7 +192,7 @@ export class GfPortfolioProportionChartComponent
} else { } else {
Object.keys(this.data).forEach((symbol) => { Object.keys(this.data).forEach((symbol) => {
chartData[symbol] = { chartData[symbol] = {
name: this.data[symbol].name, name: this.data[symbol].name ?? '',
value: new Big(this.data[symbol].value || 0) value: new Big(this.data[symbol].value || 0)
}; };
}); });
@ -487,7 +488,7 @@ export class GfPortfolioProportionChartComponent
`${value.toLocaleString(this.locale, { `${value.toLocaleString(this.locale, {
maximumFractionDigits: 2, maximumFractionDigits: 2,
minimumFractionDigits: 2 minimumFractionDigits: 2
})} ${this.baseCurrency} (${percentage.toFixed(2)}%)` })} ${this.baseCurrency ?? ''} (${percentage.toFixed(2)}%)`
]; ];
} }
}, },

Loading…
Cancel
Save