Skip to content

Commit

Permalink
Merge pull request #3944 from owid/fix-duplicate-indicators-explorers
Browse files Browse the repository at this point in the history
🐛 fix duplicate indicators in indicator-based explorers
  • Loading branch information
danyx23 authored Sep 12, 2024
2 parents bf0b8db + 0a1544a commit a83487c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions explorer/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a83487c

Please sign in to comment.