Skip to content

Commit

Permalink
🐛 fix duplicate indicators in indicator-based explorers
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Sep 10, 2024
1 parent 8b53f96 commit a3b260f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions explorer/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a3b260f

Please sign in to comment.