From c23884552529fd085378a64a0677bccb4b63eaea Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Wed, 1 May 2024 14:54:38 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(marimekko)=20do=20not=20show=20?= =?UTF-8?q?lone=20legend=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grapher/src/stackedCharts/MarimekkoChart.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/@ourworldindata/grapher/src/stackedCharts/MarimekkoChart.tsx b/packages/@ourworldindata/grapher/src/stackedCharts/MarimekkoChart.tsx index 6628f52f762..bdd1a46f770 100644 --- a/packages/@ourworldindata/grapher/src/stackedCharts/MarimekkoChart.tsx +++ b/packages/@ourworldindata/grapher/src/stackedCharts/MarimekkoChart.tsx @@ -825,7 +825,7 @@ export class MarimekkoChart // legend props @computed get legendPaddingTop(): number { - return this.baseFontSize + return this.legend.height > 0 ? this.baseFontSize : 0 } @computed get legendX(): number { @@ -858,10 +858,11 @@ export class MarimekkoChart @computed get categoricalLegendData(): CategoricalBin[] { const { colorColumnSlug, colorScale, series } = this - const customHiddenCategories = - this.colorScaleConfig?.customHiddenCategories - if (colorColumnSlug) return colorScale.categoricalLegendBins - else + if (colorColumnSlug) { + return colorScale.categoricalLegendBins + } else if (series.length > 0) { + const customHiddenCategories = + this.colorScaleConfig?.customHiddenCategories return series.map((series, index) => { return new CategoricalBin({ index, @@ -871,6 +872,8 @@ export class MarimekkoChart isHidden: !!customHiddenCategories?.[series.seriesName], }) }) + } + return [] } @action.bound onLegendMouseOver(bin: ColorScaleBin): void {