From 9a81f6471522426e03489fb754aa169b89603aff Mon Sep 17 00:00:00 2001 From: Sophia Mersmann Date: Thu, 2 Jan 2025 16:56:38 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(facet)=20make=20legend=20clicka?= =?UTF-8?q?ble=20for=20line=20and=20slope=20charts=20only=20(#4370)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grapher/src/facetChart/FacetChart.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/@ourworldindata/grapher/src/facetChart/FacetChart.tsx b/packages/@ourworldindata/grapher/src/facetChart/FacetChart.tsx index ef091fb911..e66b7faa5b 100644 --- a/packages/@ourworldindata/grapher/src/facetChart/FacetChart.tsx +++ b/packages/@ourworldindata/grapher/src/facetChart/FacetChart.tsx @@ -799,7 +799,8 @@ export class FacetChart } @action.bound onLegendClick(bin: ColorScaleBin): void { - if (!this.manager.focusArray) return + if (!this.manager.focusArray || !this.isFocusModeSupported) return + // find all series (of all facets) that are contained in the bin const seriesNames = uniq( this.intermediateChartInstances.flatMap((chartInstance) => @@ -817,6 +818,13 @@ export class FacetChart return new this.LegendClass({ manager: this }) } + @computed private get isFocusModeSupported(): boolean { + return ( + this.chartTypeName === GRAPHER_CHART_TYPES.LineChart || + this.chartTypeName === GRAPHER_CHART_TYPES.SlopeChart + ) + } + /** * In order to display a potentially long facet label in the potentially tight space, we * shrink and shorten the label as follows to prevent overlap between neighbouring labels: