From 9e19d0d6246f9098f8eac7322f5292d8f6740082 Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Thu, 30 Jan 2025 22:28:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20incorporate=20PR=20feedback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grapher/src/core/LegacyToOwidTable.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/@ourworldindata/grapher/src/core/LegacyToOwidTable.ts b/packages/@ourworldindata/grapher/src/core/LegacyToOwidTable.ts index 20836a136f..eb7c0cd8ad 100644 --- a/packages/@ourworldindata/grapher/src/core/LegacyToOwidTable.ts +++ b/packages/@ourworldindata/grapher/src/core/LegacyToOwidTable.ts @@ -11,6 +11,7 @@ import { EntityId, ErrorValue, OwidChartDimensionInterfaceWithMandatorySlug, + EntityName, } from "@ourworldindata/types" import { OwidTable, @@ -332,20 +333,19 @@ export const legacyToOwidTableAndDimensions = ( const entityColorColumnSlug = OwidTableSlugs.entityColor const valueFn = ( - entityId: EntityId | undefined + entityName: EntityName | undefined ): string | ErrorValue => { - if (!entityId) return ErrorValueTypes.UndefinedButShouldBeString - const entityName = - joinedVariablesTable.entityIdToNameMap.get(entityId) + if (!entityName) return ErrorValueTypes.UndefinedButShouldBeString return entityName && selectedEntityColors ? (selectedEntityColors[entityName] ?? ErrorValueTypes.UndefinedButShouldBeString) : ErrorValueTypes.UndefinedButShouldBeString } - const values = joinedVariablesTable.rows.map((row) => - valueFn(row.entityId) - ) + const values = + joinedVariablesTable.entityNameColumn.valuesIncludingErrorValues.map( + (entityName) => valueFn(entityName as EntityName) + ) joinedVariablesTable = joinedVariablesTable.appendColumns([ {