diff --git a/explorer/Explorer.tsx b/explorer/Explorer.tsx index 51e25ee5022..ade08649379 100644 --- a/explorer/Explorer.tsx +++ b/explorer/Explorer.tsx @@ -589,13 +589,22 @@ 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.property === DimensionProperty.y && + d.variableId === yVariableId + ) + ) + .map((yVariableId) => ({ variableId: yVariableId, property: DimensionProperty.y, - }) - }) + })) + dimensions.push(...variablesToLoad) + if (xVariableId) { const maybeXVariableId = parseIntOrUndefined(xVariableId) if (maybeXVariableId !== undefined)