Skip to content

Commit

Permalink
🐛 (grapher) guard against undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Mar 4, 2024
1 parent a569075 commit 8ee6bb0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/@ourworldindata/grapher/src/axis/Axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,12 @@ abstract class AbstractAxis {
return (this.range[0] + this.range[1]) / 2
}
}
return parseFloat(this.d3_scale(value).toFixed(1))
const placedValue = this.d3_scale(value)
if (placedValue === undefined) {
console.error(`Placed value is undefined for ${value}`)
return value
}
return parseFloat(placedValue.toFixed(1))
}

/** This function returns the inverse of place - i.e. given a screen space
Expand Down

0 comments on commit 8ee6bb0

Please sign in to comment.