Skip to content

Commit

Permalink
🐛 (facet) make legend clickable for line and slope charts only
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Jan 2, 2025
1 parent 3eda0e1 commit 3a094c8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/@ourworldindata/grapher/src/facetChart/FacetChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand All @@ -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:
Expand Down

0 comments on commit 3a094c8

Please sign in to comment.