From a3b260f16744fa14014bb8bd8c7b531d506e1d16 Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Mon, 9 Sep 2024 19:12:50 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20duplicate=20indicators=20i?= =?UTF-8?q?n=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)