From 2df1f115043729091a7fca18522a1ca774fb7fb3 Mon Sep 17 00:00:00 2001 From: Sophia Mersmann Date: Thu, 2 Jan 2025 15:51:34 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(discrete=20bar)=20thin=20zero=20li?= =?UTF-8?q?ne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grapher/src/barCharts/DiscreteBarChart.tsx | 12 ++++++++++-- .../src/stackedCharts/StackedDiscreteBarChart.tsx | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx b/packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx index 3f79cc7bdec..8fbd5992b73 100644 --- a/packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx +++ b/packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx @@ -507,8 +507,8 @@ export class DiscreteBarChart const { manager, boundsWithoutColorLegend, yAxis, innerBounds } = this const axisLineWidth = manager.isStaticAndSmall - ? GRAPHER_AXIS_LINE_WIDTH_THICK - : GRAPHER_AXIS_LINE_WIDTH_DEFAULT + ? 0.5 * GRAPHER_AXIS_LINE_WIDTH_THICK + : 0.5 * GRAPHER_AXIS_LINE_WIDTH_DEFAULT return ( <> @@ -537,6 +537,14 @@ export class DiscreteBarChart horizontalAxis={yAxis} bounds={innerBounds} strokeWidth={axisLineWidth} + // if the chart doesn't have negative values, then we + // move the zero line a little to the left to avoid + // overlap with the bars + align={ + this.hasNegative + ? HorizontalAlign.center + : HorizontalAlign.right + } /> )} {this.renderBars()} diff --git a/packages/@ourworldindata/grapher/src/stackedCharts/StackedDiscreteBarChart.tsx b/packages/@ourworldindata/grapher/src/stackedCharts/StackedDiscreteBarChart.tsx index b298d2ae160..63317a0eae4 100644 --- a/packages/@ourworldindata/grapher/src/stackedCharts/StackedDiscreteBarChart.tsx +++ b/packages/@ourworldindata/grapher/src/stackedCharts/StackedDiscreteBarChart.tsx @@ -713,7 +713,7 @@ export class StackedDiscreteBarChart