From 2c90865d6b9a9b044f0a59004c1c67619b4df87d Mon Sep 17 00:00:00 2001 From: Luis Zenteno Date: Tue, 10 Dec 2024 08:52:44 -0600 Subject: [PATCH] fix(emisions-deforestation-drivers): move tooltips to correct place --- .../selectors.js | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/components/widgets/climate/emissions-deforestation-drivers/selectors.js b/components/widgets/climate/emissions-deforestation-drivers/selectors.js index 8253efb859..893eede3a9 100644 --- a/components/widgets/climate/emissions-deforestation-drivers/selectors.js +++ b/components/widgets/climate/emissions-deforestation-drivers/selectors.js @@ -162,6 +162,21 @@ export const parseConfig = createSelector( .reverse() ); + const forestryIndex = tooltip.findIndex( + (element) => element.key === 'class_Forestry' + ); + const agricultureIndex = tooltip.findIndex( + (element) => element.key === 'class_Shifting agriculture' + ); + + const rearrengedTooltips = [...tooltip]; + + delete rearrengedTooltips[forestryIndex]; + delete rearrengedTooltips[agricultureIndex]; + + rearrengedTooltips.splice(2, 0, tooltip[forestryIndex]); + rearrengedTooltips.splice(3, 0, tooltip[agricultureIndex]); + // Example on how to add columns & titles to the Chart Legend // See: https://gfw.atlassian.net/browse/FLAG-1145 // const chartLegend = { @@ -180,9 +195,11 @@ export const parseConfig = createSelector( // ], // }; - const insertIndex = findIndex(tooltip, { key: 'class_Urbanization' }); + const insertIndex = findIndex(rearrengedTooltips, { + key: 'class_Urbanization', + }); if (insertIndex > -1) { - tooltip.splice(insertIndex, 0, { + rearrengedTooltips.splice(insertIndex, 0, { key: 'break', label: 'Drivers of permanent deforestation:', }); @@ -199,7 +216,7 @@ export const parseConfig = createSelector( unitFormat: (value) => formatNumber({ num: value, specialSpecifier: '.2s', spaceUnit: true }), unit: 'tCO2e', - tooltip, + tooltip: rearrengedTooltips, // chartLegend, }; }