From d7243d822104119767eb791607316d8774cf288d Mon Sep 17 00:00:00 2001 From: anamontiaga Date: Mon, 12 Dec 2022 14:11:39 +0100 Subject: [PATCH 1/5] add numbers of runs to solutions frequency legend --- app/hooks/map/constants.tsx | 56 +++++++++++---------- app/hooks/map/types.ts | 1 + app/layout/scenarios/edit/map/component.tsx | 1 + 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/app/hooks/map/constants.tsx b/app/hooks/map/constants.tsx index 91430c42c2..bb01f1cc31 100644 --- a/app/hooks/map/constants.tsx +++ b/app/hooks/map/constants.tsx @@ -226,33 +226,37 @@ export const LEGEND_LAYERS = { }, // SOLUTIONS - frequency: () => ({ - id: 'frequency', - name: 'Frequency', - type: 'gradient', - settingsManager: { - opacity: true, - visibility: true, - }, - items: [ - { - color: COLORS.frequency[0], - value: '0', - }, - { - color: COLORS.frequency[1], - value: null, - }, - { - color: COLORS.frequency[2], - value: null, - }, - { - color: COLORS.frequency[3], - value: '100', + frequency: (options) => { + const { numberOfRuns } = options; + + return ({ + id: 'frequency', + name: `Frequency (${numberOfRuns} runs)`, + type: 'gradient', + settingsManager: { + opacity: true, + visibility: true, }, - ], - }), + items: [ + { + color: COLORS.frequency[0], + value: '0', + }, + { + color: COLORS.frequency[1], + value: null, + }, + { + color: COLORS.frequency[2], + value: null, + }, + { + color: COLORS.frequency[3], + value: '100', + }, + ], + }); + }, solution: () => ({ id: 'solution', name: 'Solution selected', diff --git a/app/hooks/map/types.ts b/app/hooks/map/types.ts index 55bb500d3a..25ed1b3417 100644 --- a/app/hooks/map/types.ts +++ b/app/hooks/map/types.ts @@ -190,6 +190,7 @@ export interface UseLegend { puIncludedValue?: string[]; puExcludedValue?: string[]; runId?: string; + numberOfRuns?: number; layerSettings?: Record>; }; } diff --git a/app/layout/scenarios/edit/map/component.tsx b/app/layout/scenarios/edit/map/component.tsx index ca6fcdc2c3..97ff1051fa 100644 --- a/app/layout/scenarios/edit/map/component.tsx +++ b/app/layout/scenarios/edit/map/component.tsx @@ -385,6 +385,7 @@ export const ScenariosEditMap: React.FC = () => { puIncludedValue: puTmpIncludedValue, puExcludedValue: puTmpExcludedValue, runId: selectedSolution?.runId || bestSolution?.runId, + numberOfRuns: scenarioData?.numberOfRuns || 0, layerSettings, }, }); From 4c4fb44f772f52100137437cf3b4cae0371b520c Mon Sep 17 00:00:00 2001 From: anamontiaga Date: Mon, 12 Dec 2022 14:23:05 +0100 Subject: [PATCH 2/5] update node --- app/.nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/.nvmrc b/app/.nvmrc index 8bb247c432..8aeef54f8d 100644 --- a/app/.nvmrc +++ b/app/.nvmrc @@ -1 +1 @@ -14.20 +14.21 From b3cfffc7fcee6897e0ac2504636a4627a1cfd47a Mon Sep 17 00:00:00 2001 From: anamontiaga Date: Mon, 12 Dec 2022 14:35:04 +0100 Subject: [PATCH 3/5] update node --- app/.nvmrc | 2 +- app/hooks/map/constants.tsx | 2 +- .../reports/solutions/selection-frequency-page/component.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/.nvmrc b/app/.nvmrc index 8aeef54f8d..049c407af7 100644 --- a/app/.nvmrc +++ b/app/.nvmrc @@ -1 +1 @@ -14.21 +14.21.1 diff --git a/app/hooks/map/constants.tsx b/app/hooks/map/constants.tsx index bb01f1cc31..ad4934006a 100644 --- a/app/hooks/map/constants.tsx +++ b/app/hooks/map/constants.tsx @@ -231,7 +231,7 @@ export const LEGEND_LAYERS = { return ({ id: 'frequency', - name: `Frequency (${numberOfRuns} runs)`, + name: numberOfRuns ? `Frequency (${numberOfRuns} runs)` : 'Frequency', type: 'gradient', settingsManager: { opacity: true, diff --git a/app/layout/scenarios/reports/solutions/selection-frequency-page/component.tsx b/app/layout/scenarios/reports/solutions/selection-frequency-page/component.tsx index 1d4259a320..f4454a7538 100644 --- a/app/layout/scenarios/reports/solutions/selection-frequency-page/component.tsx +++ b/app/layout/scenarios/reports/solutions/selection-frequency-page/component.tsx @@ -67,7 +67,7 @@ export const SelectionFrequencyPage: React.FC = () return { id: 'frequency', name: 'Selection frequency', - items: LEGEND_LAYERS.frequency().items, + items: LEGEND_LAYERS.frequency({}).items, }; }, []); From 1609af5b0d3bfbeef66c0a2b1be626a0560b04f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Barrenechea=20S=C3=A1nchez?= Date: Wed, 14 Dec 2022 12:38:55 +0100 Subject: [PATCH 4/5] node version --- app/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/package.json b/app/package.json index c54ad4bf74..b61c50edbc 100644 --- a/app/package.json +++ b/app/package.json @@ -15,7 +15,7 @@ "storybook:build": "yarn storybook:styles:prod && build-storybook -s ./public -c .storybook" }, "engines": { - "node": "~14.20" + "node": "14.21.1" }, "dependencies": { "@artsy/fresnel": "^1.9.0", From 7e1cca64add7e9944923e3156500f5b1f53c68cb Mon Sep 17 00:00:00 2001 From: anamontiaga Date: Wed, 14 Dec 2022 16:17:28 +0100 Subject: [PATCH 5/5] add number of runs to frequency page --- .../selection-frequency-page/component.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/layout/scenarios/reports/solutions/selection-frequency-page/component.tsx b/app/layout/scenarios/reports/solutions/selection-frequency-page/component.tsx index f4454a7538..1c1fc08ac3 100644 --- a/app/layout/scenarios/reports/solutions/selection-frequency-page/component.tsx +++ b/app/layout/scenarios/reports/solutions/selection-frequency-page/component.tsx @@ -5,6 +5,7 @@ import { useRouter } from 'next/router'; import { LEGEND_LAYERS } from 'hooks/map/constants'; import { useProjectUsers } from 'hooks/project-users'; import { useProject } from 'hooks/projects'; +import { useScenario } from 'hooks/scenarios'; import { useWDPACategories } from 'hooks/wdpa'; import ScenarioReportsMap from 'layout/scenarios/reports/solutions/selection-frequency-page/map'; @@ -45,6 +46,10 @@ export const SelectionFrequencyPage: React.FC = () scenarioId: sid, }); + const { + data: scenarioData, + } = useScenario(sid); + const protectedAreas = useMemo(() => { return protectedAreasData?.sort((a, b) => { if (a.kind === 'project') return 1; @@ -67,9 +72,13 @@ export const SelectionFrequencyPage: React.FC = () return { id: 'frequency', name: 'Selection frequency', - items: LEGEND_LAYERS.frequency({}).items, + items: LEGEND_LAYERS.frequency({ + options: { + numberOfRuns: scenarioData?.numberOfRuns || 0, + }, + }).items, }; - }, []); + }, [scenarioData?.numberOfRuns]); const reportDataIsFetched = projectDataIsFetched && projectUsersDataIsFetched && protectedAreasDataIsFetched;