diff --git a/packages/@ourworldindata/core-table/src/CoreTableColumns.ts b/packages/@ourworldindata/core-table/src/CoreTableColumns.ts index a23575ea8dc..05132fff1bd 100644 --- a/packages/@ourworldindata/core-table/src/CoreTableColumns.ts +++ b/packages/@ourworldindata/core-table/src/CoreTableColumns.ts @@ -282,11 +282,7 @@ export abstract class AbstractCoreColumn { attributionShort: this.def.presentation?.attributionShort, titleVariant: this.def.presentation?.titleVariant, } - : { title: this.display?.name ?? this.name ?? "" } - } - - @imemo get nonEmptyDisplayName(): string { - return this.display?.name || this.nonEmptyName + : { title: this.display?.name || this.name || "" } } @imemo get datasetId(): number | undefined { diff --git a/packages/@ourworldindata/grapher/src/core/Grapher.tsx b/packages/@ourworldindata/grapher/src/core/Grapher.tsx index 1026c00835a..e032c14fb21 100644 --- a/packages/@ourworldindata/grapher/src/core/Grapher.tsx +++ b/packages/@ourworldindata/grapher/src/core/Grapher.tsx @@ -1475,7 +1475,7 @@ export class Grapher // sort y-columns by their display name const sortedYColumnSlugs = sortBy( yColumnSlugs, - (slug) => this.inputTable.get(slug).nonEmptyDisplayName + (slug) => this.inputTable.get(slug).titlePublicOrDisplayName ) const columnSlugs = excludeUndefined([ diff --git a/packages/@ourworldindata/grapher/src/dataTable/DataTable.tsx b/packages/@ourworldindata/grapher/src/dataTable/DataTable.tsx index 3212b2ee107..b3678348263 100644 --- a/packages/@ourworldindata/grapher/src/dataTable/DataTable.tsx +++ b/packages/@ourworldindata/grapher/src/dataTable/DataTable.tsx @@ -549,21 +549,29 @@ export class DataTable extends React.Component<{ @computed private get tableCaption(): JSX.Element | null { if (this.hasDimensionHeaders) return null const singleDimension = this.displayDimensions[0] + const titleFragments = (singleDimension.display.columnName + .attributionShort || + singleDimension.display.columnName.titleVariant) && ( + <> + + {joinTitleFragments( + singleDimension.display.columnName.attributionShort, + singleDimension.display.columnName.titleVariant + )} + + + ) + const separator = + (singleDimension.display.columnName.attributionShort || + singleDimension.display.columnName.titleVariant) && + singleDimension.display.unit + ? " – " + : " " + return singleDimension ? (
- {singleDimension.display.columnName.title}{" "} - {(singleDimension.display.columnName.attributionShort || - singleDimension.display.columnName.titleVariant) && ( - <> - - {joinTitleFragments( - singleDimension.display.columnName - .attributionShort, - singleDimension.display.columnName.titleVariant - )} - {" "} - - )} + {singleDimension.display.columnName.title} {titleFragments} + {separator} {singleDimension.display.unit && ( {singleDimension.display.unit} )}