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 7ff9e9f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/@ourworldindata/grapher/src/core/Grapher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ export class Grapher
// irrespective of the time range the user might have selected on the table tab
if (this.isOnChartTab && this.hideTimeline && this.hasTimeDimension) {
const { minTime, maxTime } = this.authorsVersion
console.log("minTime", minTime, "maxTime", maxTime)

Check warning on line 1195 in packages/@ourworldindata/grapher/src/core/Grapher.tsx

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement

Check warning on line 1195 in packages/@ourworldindata/grapher/src/core/Grapher.tsx

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement

Check warning on line 1195 in packages/@ourworldindata/grapher/src/core/Grapher.tsx

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
return [
minTimeBoundFromJSONOrNegativeInfinity(minTime),
maxTimeBoundFromJSONOrPositiveInfinity(maxTime),
Expand Down Expand Up @@ -1749,17 +1750,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 7ff9e9f

Please sign in to comment.