Skip to content

Commit

Permalink
🔨 introduce displayUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Jan 13, 2025
1 parent 591b9a6 commit 1bd5220
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/@ourworldindata/core-table/src/CoreTableColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ export abstract class AbstractCoreColumn<JS_TYPE extends PrimitiveType> {
return undefined
}

@imemo get displayUnit(): string | undefined {
return this.unit && this.unit !== this.shortUnit
? this.unit.replace(/^\((.*)\)$/, "$1")
: undefined
}

// Returns a map where the key is a series slug such as "name" and the value is a set
// of all the unique values that this column has for that particular series.
getUniqueValuesGroupedBy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ class Variable extends React.Component<{

if (column.isMissing || column.name === "time") return null

const { unit, shortUnit, displayName } = column,
displayUnit =
unit && unit !== shortUnit
? unit.replace(/^\((.*)\)$/, "$1")
: undefined,
const { displayUnit, displayName } = column,
displayNotice =
uniq((notice ?? []).filter((t) => t !== undefined))
.map((time) =>
Expand Down

0 comments on commit 1bd5220

Please sign in to comment.