Skip to content

Commit

Permalink
🐛 (stacked bar/area) show timeline on table tab
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Apr 15, 2024
1 parent ba2346b commit fff5caf
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions packages/@ourworldindata/grapher/src/core/Grapher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,19 @@ export class Grapher
)
}

/**
* Plots time on the x-axis.
*/
@computed private get hasTimeDimension(): boolean {
return this.isStackedBar || this.isStackedArea || this.isLineChart
}

@computed get startHandleTimeBound(): TimeBound {
// If time is plotted on the x-axis and the timeline is hidden, we always want to show the authored `minTime`
// irrespective of the time range the user might have selected on the table tab
if (this.hasTimeDimension && this.hideTimeline && this.isOnChartTab) {
return this.authorsVersion.minTime ?? -Infinity
}
if (this.onlySingleTimeSelectionPossible) return this.endHandleTimeBound
return this.timelineHandleTimeBounds[0]
}
Expand All @@ -1056,6 +1068,11 @@ export class Grapher
}

@computed get endHandleTimeBound(): TimeBound {
// If time is plotted on the x-axis and the timeline is hidden, we always want to show the authored `maxTime`
// irrespective of the time range the user might have selected on the table tab
if (this.hasTimeDimension && this.hideTimeline && this.isOnChartTab) {
return this.authorsVersion.maxTime ?? -Infinity
}
return this.timelineHandleTimeBounds[1]
}

Expand Down Expand Up @@ -1422,11 +1439,16 @@ export class Grapher
case GrapherTabOption.map:
return !this.map.hideTimeline

// use the chart-level `hideTimeline` option for the table, too
case GrapherTabOption.table:
// use the chart-level `hideTimeline` option
case GrapherTabOption.chart:
return !this.hideTimeline

// use the chart-level `hideTimeline` option for the table, with some exceptions
case GrapherTabOption.table:
// always show the timeline for charts that plot time on the x-axis
if (this.hasTimeDimension) return true
return !this.hideTimeline

default:
return false
}
Expand Down

0 comments on commit fff5caf

Please sign in to comment.