From a3b260f16744fa14014bb8bd8c7b531d506e1d16 Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Mon, 9 Sep 2024 19:12:50 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix=20duplicate=20indicators?= =?UTF-8?q?=20in=20indicator-based=20explorers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- explorer/Explorer.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/explorer/Explorer.tsx b/explorer/Explorer.tsx index 51e25ee5022..95e0b226f9f 100644 --- a/explorer/Explorer.tsx +++ b/explorer/Explorer.tsx @@ -589,13 +589,18 @@ export class Explorer // set given variable IDs as dimensions to make Grapher // download the data and metadata for these variables const dimensions = config.dimensions ?? [] - - yVariableIdsList.forEach((yVariableId) => { - dimensions.push({ + const variablesToLoad = yVariableIdsList + // Filter out variableIds that are already present in the dimensions array + .filter( + (yVariableId) => + !dimensions.some((d) => d.variableId === yVariableId) + ) + .map((yVariableId) => ({ variableId: yVariableId, property: DimensionProperty.y, - }) - }) + })) + dimensions.push(...variablesToLoad) + if (xVariableId) { const maybeXVariableId = parseIntOrUndefined(xVariableId) if (maybeXVariableId !== undefined) From 0a1544a3572d5dfadd4ff258c9b3d253cc171791 Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Tue, 10 Sep 2024 09:12:00 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20only=20filter=20out=20duplicate?= =?UTF-8?q?d=20y=20dimensions=20from=20explorers=20before=20loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- explorer/Explorer.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/explorer/Explorer.tsx b/explorer/Explorer.tsx index 95e0b226f9f..ade08649379 100644 --- a/explorer/Explorer.tsx +++ b/explorer/Explorer.tsx @@ -593,7 +593,11 @@ export class Explorer // Filter out variableIds that are already present in the dimensions array .filter( (yVariableId) => - !dimensions.some((d) => d.variableId === yVariableId) + !dimensions.some( + (d) => + d.property === DimensionProperty.y && + d.variableId === yVariableId + ) ) .map((yVariableId) => ({ variableId: yVariableId,