Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 support disconnecting lines in explorers / TAS-797 #4405

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/@ourworldindata/explorer/src/ColumnGrammar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { ToleranceStrategy } from "@ourworldindata/utils"
import {
BooleanCellDef,
ColumnCellDef,
EnumCellDef,
EtlPathCellDef,
Grammar,
Expand All @@ -17,7 +18,7 @@ import {
UrlCellDef,
} from "./gridLang/GridLangConstants.js"

export const ColumnGrammar: Grammar = {
export const ColumnGrammar: Grammar<ColumnCellDef> = {
variableId: {
...IntegerCellDef,
keyword: "variableId",
Expand Down Expand Up @@ -206,4 +207,10 @@ export const ColumnGrammar: Grammar = {
" Example: one,#ccc,uno; two,,dos",
].join("\n"),
},
plotMarkersOnlyInLineChart: {
...BooleanCellDef,
keyword: "plotMarkersOnlyInLineChart",
description: "Should data points be connected by a line?",
display: true,
},
} as const
22 changes: 15 additions & 7 deletions packages/@ourworldindata/explorer/src/ExplorerProgram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,21 @@ const parseColumnDefs = (block: string[][]): OwidColumnDef[] => {
"Keep only column defs with a slug or variable id"
)
return columnsTable.rows.map((row) => {
// ignore slug if variable id is given
if (
row.owidVariableId &&
isNotErrorValue(row.owidVariableId) &&
row.slug
)
delete row.slug
// ignore slug if a variable id is given
const hasValidVariableId =
row.owidVariableId && isNotErrorValue(row.owidVariableId)
if (hasValidVariableId && row.slug) delete row.slug

for (const field in row) {
const cellDef = ColumnGrammar[field]
if (cellDef?.display) {
// move field into 'display' object
row.display = row.display || {}
row.display[field] = row[field]
delete row[field]
}
}

return trimAndParseObject(row, ColumnGrammar)
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export interface GrapherCellDef extends CellDef {
toGrapherObject: (value: any) => GrapherInterface // map to a partial config that is a valid GrapherInterface
}

export interface ColumnCellDef extends CellDef {
display?: boolean
}

export interface ParsedCell {
errorMessage?: string
cssClasses?: string[]
Expand Down
Loading