Skip to content

Commit

Permalink
🐛 (grapher) hide axis labels when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Nov 24, 2023
1 parent 6a111fb commit e758c6b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion packages/@ourworldindata/core-table/src/CoreTableColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,19 @@ export abstract class AbstractCoreColumn<JS_TYPE extends PrimitiveType> {
}

@imemo get name(): string {
return this.def.name ?? this.def.slug
}

@imemo get nonEmptyName(): string {
return this.def.name || this.def.slug
}

@imemo get displayName(): string {
return this.display?.name || this.name || ""
return this.display?.name ?? this.name ?? ""
}

@imemo get nonEmptyDisplayName(): string {
return this.display?.name || this.nonEmptyName
}

@imemo get datasetId(): number | undefined {
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/grapher/src/core/Grapher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ export class Grapher
// sort y-columns by their display name
const sortedYColumnSlugs = sortBy(
yColumnSlugs,
(slug) => this.inputTable.get(slug).displayName
(slug) => this.inputTable.get(slug).nonEmptyDisplayName
)

const columnSlugs = excludeUndefined([
Expand Down
4 changes: 2 additions & 2 deletions packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class SourcesModal extends React.Component<
}

@computed private get tabLabels(): string[] {
return this.columns.map((column) => column.displayName)
return this.columns.map((column) => column.nonEmptyDisplayName)
}

private renderSource(column: CoreColumn | undefined): JSX.Element | null {
Expand Down Expand Up @@ -223,7 +223,7 @@ export class Source extends React.Component<{
}

@computed private get title(): string {
return this.props.column.displayName
return this.props.column.nonEmptyDisplayName
}

@computed private get editUrl(): string | undefined {
Expand Down

0 comments on commit e758c6b

Please sign in to comment.