From 03210d9f0b95f8fd40400d408dc7ff5e3b1e3df0 Mon Sep 17 00:00:00 2001 From: Stefanos Hadjipetrou Date: Wed, 12 Jun 2024 15:40:43 +0300 Subject: [PATCH] feat: data additions for chart tooltips --- src/config/mapping/allocations/radial.json | 3 ++- src/controllers/allocations.controller.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/config/mapping/allocations/radial.json b/src/config/mapping/allocations/radial.json index 317a317..2832b38 100644 --- a/src/config/mapping/allocations/radial.json +++ b/src/config/mapping/allocations/radial.json @@ -5,7 +5,8 @@ "tooltipItem": "geography.parent.parent.name", "value": "value", "countryCode": "geography/code", - "urlParams": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate')/groupby((activityArea/name),aggregate(actualAmount with sum as value))", + "urlParams": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate')/groupby((activityArea/name,geography/parent/parent/name),aggregate(actualAmount with sum as value))", + "urlParamsLocation": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate')/groupby((activityArea/name),aggregate(actualAmount with sum as value))", "countriesCountUrlParams": "?$apply=filter(indicatorName eq 'Communicated Allocation - Reference Rate' AND financialDataSet eq 'CommunicatedAllocation_ReferenceRate')/groupby((geography/name))", "colors": ["#0A2840", "#013E77", "#00B5AE", "#C3EDFD"] } diff --git a/src/controllers/allocations.controller.ts b/src/controllers/allocations.controller.ts index e78ba66..8533fa9 100644 --- a/src/controllers/allocations.controller.ts +++ b/src/controllers/allocations.controller.ts @@ -81,6 +81,9 @@ async function getAllocationsData(url: string) { items: groupedByName[name].map((item: any) => ({ name: _.get(item, AllocationRadialFieldsMapping.tooltipItem, ''), value: _.get(item, AllocationRadialFieldsMapping.value, 0), + percentage: + (_.get(item, AllocationRadialFieldsMapping.value, 0) / value) * + 100, })), }, }); @@ -419,7 +422,7 @@ export class AllocationsController { ) { let filterString = filterFinancialIndicators( {...this.req.query, geographies: countryCode}, - AllocationRadialFieldsMapping.urlParams, + AllocationRadialFieldsMapping.urlParamsLocation, ); const url = `${urls.FINANCIAL_INDICATORS}/${filterString}`;