Skip to content

Commit

Permalink
🔨 Set dimensions again after loading the input table
Browse files Browse the repository at this point in the history
(tests and svg tester were green without it, probably not necessary
and will be replaced in a later PR)
  • Loading branch information
danyx23 committed Feb 3, 2025
1 parent d148826 commit a023ee0
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions packages/@ourworldindata/grapher/src/core/Grapher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import {
GrapherTabOption,
SeriesName,
ChartViewInfo,
OwidChartDimensionInterfaceWithMandatorySlug,
} from "@ourworldindata/types"
import {
BlankOwidTable,
Expand Down Expand Up @@ -1180,18 +1181,19 @@ export class Grapher
// TODO grapher model: switch this to downloading multiple data and metadata files

const startMark = performance.now()
const dimensions = legacyConfig.dimensions?.map((dimension) => ({
...dimension,
slug:
dimension.slug ??
getDimensionColumnSlug(
dimension.variableId,
dimension.targetYear
),
}))
const dimensions: OwidChartDimensionInterfaceWithMandatorySlug[] =
legacyConfig.dimensions?.map((dimension) => ({
...dimension,
slug:
dimension.slug ??
getDimensionColumnSlug(
dimension.variableId,
dimension.targetYear
),
})) ?? []
const tableWithColors = legacyToOwidTableAndDimensions(
json,
dimensions ?? [],
dimensions,
legacyConfig.selectedEntityColors
)
this.createPerformanceMeasurement(
Expand All @@ -1203,6 +1205,10 @@ export class Grapher
this.inputTable = inputTableTransformer(tableWithColors)
else this.inputTable = tableWithColors

// We need to reset the dimensions because some of them may have changed slugs in the legacy
// transformation (can happen when columns use targetTime)
this.setDimensionsFromConfigs(dimensions)

this.appendNewEntitySelectionOptions()

if (this.manager?.selection?.hasSelection) {
Expand Down

0 comments on commit a023ee0

Please sign in to comment.