Skip to content

Commit

Permalink
Add grapher config schema to mdim chart configs
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyi committed Oct 30, 2024
1 parent 4cbc892 commit 67c71eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion adminSiteServer/multiDim.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { uniq } from "lodash"
import { uuidv7 } from "uuidv7"

import { migrateGrapherConfigToLatestVersion } from "@ourworldindata/grapher"
import {
Base64String,
ChartConfigsTableName,
Expand Down Expand Up @@ -284,11 +285,21 @@ export async function createMultiDimConfig(
const enrichedViews = await Promise.all(
config.views.map(async (view) => {
const variableId = view.indicators.y[0]
const patchGrapherConfig = view.config || {}
let patchGrapherConfig = {}
if (view.config) {
patchGrapherConfig = config.grapherConfigSchema
? migrateGrapherConfigToLatestVersion({
...view.config,
$schema: config.grapherConfigSchema,
})
: view.config
}
const fullGrapherConfig = mergeGrapherConfigs(
variableConfigs.get(variableId) ?? {},
patchGrapherConfig,
{
$schema:
"https://files.ourworldindata.org/schemas/grapher-schema.005.json",
dimensions:
MultiDimDataPageConfig.viewToDimensionsConfig(view),
selectedEntityNames: config.defaultSelection ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Metadata = Omit<OwidVariableWithSource, "id">
interface MultiDimDataPageConfigType<
IndicatorType extends Record<string, any>,
> {
grapherConfigSchema?: string
title: IndicatorTitleWithFragments
defaultSelection?: string[]
topicTags?: string[]
Expand Down

0 comments on commit 67c71eb

Please sign in to comment.