From 3031aa43f8b01c2ad021ae93570e05971e1827d6 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 11:18:28 -0300 Subject: [PATCH 1/7] feat(tree-cover): change tree cover by type name to tree coover --- components/widgets/land-cover/tree-cover/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/index.js b/components/widgets/land-cover/tree-cover/index.js index ad5415a613..ad4af68e0a 100644 --- a/components/widgets/land-cover/tree-cover/index.js +++ b/components/widgets/land-cover/tree-cover/index.js @@ -24,9 +24,8 @@ import getWidgetProps from './selectors'; export default { widget: 'treeCover', title: { - default: 'Tree Cover by type in {location}', - global: 'Global tree cover by type', - withPlantations: 'Forest cover by type in {location}', + default: 'Tree Cover in {location}', + global: 'Global tree cover', }, alerts: [ { From 572ff716490112821d7da6e25b0b777e6c0e1b2f Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 11:27:18 -0300 Subject: [PATCH 2/7] feat(tree-cover): add plantations intersection --- .../widgets/land-cover/tree-cover/index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/components/widgets/land-cover/tree-cover/index.js b/components/widgets/land-cover/tree-cover/index.js index ad4af68e0a..c710603369 100644 --- a/components/widgets/land-cover/tree-cover/index.js +++ b/components/widgets/land-cover/tree-cover/index.js @@ -108,7 +108,13 @@ export default { summary: 4, landCover: 1, }, - refetchKeys: ['threshold', 'decile', 'extentYear', 'landCategory'], + refetchKeys: [ + 'threshold', + 'decile', + 'extentYear', + 'landCategory', + 'forestType', + ], pendingKeys: ['threshold', 'decile', 'extentYear'], settings: { threshold: 30, @@ -139,6 +145,14 @@ export default { clearable: true, border: true, }, + { + key: 'forestType', + whitelist: ['plantations'], + label: 'Forest Type', + type: 'select', + placeholder: 'All tree cover', + clearable: true, + }, { key: isTropicalTreeCover ? 'decile' : 'threshold', label: 'Tree cover', From fd213d0eeafce64081a3263e292c9d06f10d211a Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 12:26:07 -0300 Subject: [PATCH 3/7] feat(tree-cover): adjust chart data when plantations is selected --- .../land-cover/tree-cover/selectors.js | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/selectors.js b/components/widgets/land-cover/tree-cover/selectors.js index c95a4f9d47..5b71dffa49 100644 --- a/components/widgets/land-cover/tree-cover/selectors.js +++ b/components/widgets/land-cover/tree-cover/selectors.js @@ -28,21 +28,23 @@ export const isoHasPlantations = createSelector( ); export const parseData = createSelector( - [getData, getColors, getIndicator, isoHasPlantations], - (data, colors, indicator, hasPlantations) => { + [getData, getColors, getIndicator], + (data, colors, indicator) => { if (isEmpty(data)) return null; const { totalArea, totalCover, cover, plantations } = data; const otherCover = indicator ? totalCover - cover : 0; - const plantationsCover = hasPlantations ? plantations : 0; + const plantationsCover = plantations || 0; const label = indicator ? ` in ${indicator.label}` : ''; + const indicators = indicator?.value?.split('__') || []; + const hasPlantations = indicators.includes('plantations'); + const parsedData = [ { - label: hasPlantations - ? 'Natural Forest'.concat(label) - : 'Tree Cover'.concat(label), - value: cover - plantationsCover, + label: 'Tree Cover'.concat(label), + value: hasPlantations ? plantationsCover : cover - plantationsCover, color: colors.naturalForest, - percentage: ((cover - plantationsCover) / totalArea) * 100, + percentage: + ((hasPlantations ? plantationsCover : cover) / totalArea) * 100, }, { label: 'Other Land Cover', @@ -51,21 +53,16 @@ export const parseData = createSelector( percentage: ((totalArea - cover - otherCover) / totalArea) * 100, }, ]; - if (indicator) { + + if (hasPlantations) { parsedData.splice(1, 0, { - label: hasPlantations ? 'Other forest cover' : 'Other tree cover', + label: 'Other tree cover', value: otherCover, color: colors.otherCover, percentage: (otherCover / totalArea) * 100, }); - } else if (!indicator && hasPlantations) { - parsedData.splice(1, 0, { - label: 'Plantations', - value: plantations, - color: colors.plantedForest, - percentage: (plantations / totalArea) * 100, - }); } + return parsedData; } ); From 0bf1e2702703a06706cbdd0defe0e36ee7f80db4 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 12:26:57 -0300 Subject: [PATCH 4/7] feat(tree-cover): adjust widget sentence for plantations intersection --- .../widgets/land-cover/tree-cover/selectors.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/selectors.js b/components/widgets/land-cover/tree-cover/selectors.js index 5b71dffa49..099ab0f715 100644 --- a/components/widgets/land-cover/tree-cover/selectors.js +++ b/components/widgets/land-cover/tree-cover/selectors.js @@ -82,17 +82,8 @@ export const parseSentence = createSelector( getIndicator, getSentence, getAdminLevel, - isoHasPlantations, ], - ( - data, - settings, - locationName, - indicator, - sentences, - admLevel, - isoPlantations - ) => { + (data, settings, locationName, indicator, sentences, admLevel) => { if (!data || !sentences) return null; const { extentYear, threshold, decile } = settings; @@ -108,9 +99,11 @@ export const parseSentence = createSelector( : 'treeCover'; const sentence = sentences[sentenceKey][sentenceSubkey][sentenceTreeCoverType]; + const indicators = indicator?.value?.split('__') || []; + const hasPlantations = indicators.includes('plantations'); const { cover, plantations, totalCover, totalArea } = data; - const top = isoPlantations ? cover - plantations : cover; + const top = !hasPlantations ? cover - plantations : plantations; const bottom = indicator ? totalCover : totalArea; const percentCover = (100 * top) / bottom; From f355452d52c98dae440c04af3187e68239991106 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 12:27:16 -0300 Subject: [PATCH 5/7] feat(tree-cover): change chart colors --- data/colors.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/colors.json b/data/colors.json index eaf308194b..9150404417 100644 --- a/data/colors.json +++ b/data/colors.json @@ -17,7 +17,7 @@ "intactForest": "#6b8729", "primaryForest": "#84a637", "plantedForest": "#a0c746", - "otherCover": "#c7e67c", + "otherCover": "#a0c746", "nonForest": "#e7e5a4" }, "loss": { From f94522700da657723d56319bc836bc95cb84b54e Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 12:37:16 -0300 Subject: [PATCH 6/7] feat(tree-cover): remove out dated method --- .../widgets/land-cover/tree-cover/selectors.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/selectors.js b/components/widgets/land-cover/tree-cover/selectors.js index 099ab0f715..9e2235889f 100644 --- a/components/widgets/land-cover/tree-cover/selectors.js +++ b/components/widgets/land-cover/tree-cover/selectors.js @@ -6,7 +6,6 @@ import { formatNumber } from 'utils/format'; const getData = (state) => state.data; const getSettings = (state) => state.settings; const getIndicator = (state) => state.indicator; -const getWhitelist = (state) => state.polynamesWhitelist; const getColors = (state) => state.colors; const getSentence = (state) => state.sentence; const getTitle = (state) => state.title; @@ -14,19 +13,6 @@ const getLocationName = (state) => state.locationLabel; const getMetaKey = (state) => state.metaKey; const getAdminLevel = (state) => state.adminLevel; -export const isoHasPlantations = createSelector( - [getWhitelist, getLocationName], - (whitelist, name) => { - const hasPlantations = - name === 'global' - ? true - : whitelist && - whitelist.annual && - whitelist.annual.includes('plantations'); - return hasPlantations; - } -); - export const parseData = createSelector( [getData, getColors, getIndicator], (data, colors, indicator) => { From 655e7d2b4dafa15b6b7bfd2972370dd076d6857b Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 11 Oct 2024 11:33:02 -0300 Subject: [PATCH 7/7] chore(land-categories): set preserveString as true for Indigenous and Community Lands When this property is true it keeps the label as it's written --- data/land-categories.js | 1 + 1 file changed, 1 insertion(+) diff --git a/data/land-categories.js b/data/land-categories.js index 80a0cf9ffd..9acaf5f5a9 100644 --- a/data/land-categories.js +++ b/data/land-categories.js @@ -93,6 +93,7 @@ export default [ }, { label: 'Indigenous and Community Lands', + preserveString: true, value: 'landmark', dataType: 'keyword', metaKey: 'landmark_icls_2020',