diff --git a/packages/@ourworldindata/grapher/src/axis/AxisViews.tsx b/packages/@ourworldindata/grapher/src/axis/AxisViews.tsx
index 20208efac60..96c220c8253 100644
--- a/packages/@ourworldindata/grapher/src/axis/AxisViews.tsx
+++ b/packages/@ourworldindata/grapher/src/axis/AxisViews.tsx
@@ -138,12 +138,28 @@ export class HorizontalAxisZeroLine extends React.Component<{
horizontalAxis: HorizontalAxis
bounds: Bounds
strokeWidth?: number
+ align?: HorizontalAlign
}> {
render(): React.ReactElement {
- const { bounds, horizontalAxis, strokeWidth } = this.props
+ const {
+ bounds,
+ horizontalAxis,
+ align = HorizontalAlign.center,
+ strokeWidth = 1,
+ } = this.props
const axis = horizontalAxis.clone()
axis.range = bounds.xRange()
+ // the zero line is either drawn at the center of the zero tick
+ // or at the edge of the tick, either to the left or to the right
+ const offset =
+ align === HorizontalAlign.center
+ ? 0
+ : align === HorizontalAlign.right
+ ? -strokeWidth / 2
+ : strokeWidth / 2
+ const x = axis.place(0) + offset
+
return (
>
)}
+ {!this.isLogScale && (
+
+ )}
{sizedSeries.map((series) => {
// Todo: add a "placedSeries" getter to get the transformed series, then just loop over the placedSeries and render a bar for each
const isNegative = series.value < 0
@@ -560,13 +575,6 @@ export class DiscreteBarChart
return result
})}
- {!this.isLogScale && (
-
- )}
)
}
diff --git a/packages/@ourworldindata/grapher/src/stackedCharts/StackedDiscreteBarChart.tsx b/packages/@ourworldindata/grapher/src/stackedCharts/StackedDiscreteBarChart.tsx
index 6d435b100d0..2d748c447ed 100644
--- a/packages/@ourworldindata/grapher/src/stackedCharts/StackedDiscreteBarChart.tsx
+++ b/packages/@ourworldindata/grapher/src/stackedCharts/StackedDiscreteBarChart.tsx
@@ -720,6 +720,14 @@ export class StackedDiscreteBarChart
/>
>
)}
+
{this.showLegend && (
)}
@@ -733,11 +741,6 @@ export class StackedDiscreteBarChart
{nodes.map((node) => renderRow(node))}
)}
-
{this.Tooltip}
)