From ce34f6fa9fae187dec1a5787b7c3eb6b9047c107 Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Mon, 8 Apr 2024 10:52:15 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(stacked=20bar/area)=20show=20ti?= =?UTF-8?q?meline=20on=20table=20tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grapher/src/core/Grapher.tsx | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/@ourworldindata/grapher/src/core/Grapher.tsx b/packages/@ourworldindata/grapher/src/core/Grapher.tsx index a139eacf68f..f141ff35e06 100644 --- a/packages/@ourworldindata/grapher/src/core/Grapher.tsx +++ b/packages/@ourworldindata/grapher/src/core/Grapher.tsx @@ -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] } @@ -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] } @@ -1427,11 +1444,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 }