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 a43a823 commit 22a2283
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/@ourworldindata/grapher/src/facetChart/FacetChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,13 @@ export class FacetChart
return this.isNumericLegend ? this.numericLegend : this.categoryLegend
}

@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 Expand Up @@ -853,7 +860,9 @@ export class FacetChart
onMouseLeave={this.onLegendMouseLeave}
hoverColors={this.hoverColors}
activeColors={this.activeColors}
onClick={this.onLegendClick}
onClick={
this.isFocusModeSupported ? this.onLegendClick : undefined
}
/>
)
}
Expand Down

0 comments on commit 22a2283

Please sign in to comment.