Browse Source

Task/widen input types in world map and top holdings components

pull/8017/head
KenTandrian 2 weeks ago
parent
commit
1b54211bfe
  1. 10
      libs/ui/src/lib/top-holdings/top-holdings.component.ts
  2. 34
      libs/ui/src/lib/world-map-chart/world-map-chart.component.ts

10
libs/ui/src/lib/top-holdings/top-holdings.component.ts

@ -38,11 +38,11 @@ import { GfValueComponent } from '../value/value.component';
templateUrl: './top-holdings.component.html' templateUrl: './top-holdings.component.html'
}) })
export class GfTopHoldingsComponent implements OnChanges { export class GfTopHoldingsComponent implements OnChanges {
@Input() baseCurrency: string; @Input() public baseCurrency?: string;
@Input() hasPermissionToShowValues = true; @Input() public hasPermissionToShowValues = true;
@Input() locale = getLocale(); @Input() public locale?: string = getLocale();
@Input() pageSize = Number.MAX_SAFE_INTEGER; @Input() public pageSize = Number.MAX_SAFE_INTEGER;
@Input() topHoldings: HoldingWithParents[]; @Input() public topHoldings?: HoldingWithParents[];
@Output() holdingClicked = new EventEmitter<AssetProfileIdentifier>(); @Output() holdingClicked = new EventEmitter<AssetProfileIdentifier>();

34
libs/ui/src/lib/world-map-chart/world-map-chart.component.ts

@ -23,10 +23,12 @@ import svgMap from 'svgmap';
templateUrl: './world-map-chart.component.html' templateUrl: './world-map-chart.component.html'
}) })
export class GfWorldMapChartComponent implements OnChanges, OnDestroy { export class GfWorldMapChartComponent implements OnChanges, OnDestroy {
@Input() countries: { [code: string]: { name?: string; value: number } }; @Input() public countries?: {
@Input() format: string; [code: string]: { name?: string; value: number };
@Input() isInPercentage = false; };
@Input() locale = getLocale(); @Input() public format?: string;
@Input() public isInPercentage?: boolean = false;
@Input() public locale?: string = getLocale();
public isLoading = true; public isLoading = true;
public svgMapElement: any; public svgMapElement: any;
@ -51,23 +53,29 @@ export class GfWorldMapChartComponent implements OnChanges, OnDestroy {
} }
private initialize() { private initialize() {
if (!this.countries) {
return;
}
const countries = this.countries;
if (this.isInPercentage) { if (this.isInPercentage) {
// Convert value of countries to percentage // Convert value of countries to percentage
let sum = 0; let sum = 0;
Object.keys(this.countries).map((country) => { Object.keys(countries).map((country) => {
sum += this.countries[country].value; sum += countries[country].value;
}); });
Object.keys(this.countries).map((country) => { Object.keys(countries).map((country) => {
this.countries[country].value = Number( countries[country].value = Number(
((this.countries[country].value * 100) / sum).toFixed(2) ((countries[country].value * 100) / sum).toFixed(2)
); );
}); });
} else { } else {
// Convert value to fixed-point notation // Convert value to fixed-point notation
Object.keys(this.countries).map((country) => { Object.keys(countries).map((country) => {
this.countries[country].value = Number( countries[country].value = Number(
this.countries[country].value.toFixed(2) countries[country].value.toFixed(2)
); );
}); });
} }
@ -84,7 +92,7 @@ export class GfWorldMapChartComponent implements OnChanges, OnDestroy {
thousandSeparator: getNumberFormatGroup(this.locale) thousandSeparator: getNumberFormatGroup(this.locale)
} }
}, },
values: this.countries values: countries
}, },
hideFlag: true, hideFlag: true,
minZoom: 1.06, minZoom: 1.06,

Loading…
Cancel
Save