Skip to content

Commit

Permalink
🐛 don't switch to discrete bar chart when timeline is hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed May 13, 2024
1 parent 798bc9c commit c4917ba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/@ourworldindata/grapher/src/core/Grapher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1749,17 +1749,19 @@ export class Grapher
@computed get isLineChartThatTurnedIntoDiscreteBar(): boolean {
if (!this.isLineChart) return false

const [minTime, maxTime] = this.timelineHandleTimeBounds

// This is the easy case: minTime and maxTime are the same, no need to do
// more fancy checks
if (this.minTime === this.maxTime) return true
if (minTime === maxTime) return true

// We can have cases where minTime = Infinity and/or maxTime = -Infinity,
// but still only a single year is selected.
// To check for that we need to look at the times array.
const times = this.tableAfterAuthorTimelineFilter.timeColumn.uniqValues
const minTime = findClosestTime(times, this.minTime ?? -Infinity)
const maxTime = findClosestTime(times, this.maxTime ?? Infinity)
return minTime !== undefined && minTime === maxTime
const closestMinTime = findClosestTime(times, minTime)
const closestMaxTime = findClosestTime(times, maxTime)
return closestMinTime !== undefined && closestMinTime === closestMaxTime
}

@computed get supportsMultipleYColumns(): boolean {
Expand Down

0 comments on commit c4917ba

Please sign in to comment.