From dd46db515ed595825d983d00a01eae8d7d36418b Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Wed, 31 Jul 2024 13:19:52 +0100 Subject: [PATCH] fix: fix custom sort for DiscreteBarChart --- .../grapher/src/barCharts/DiscreteBarChart.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx b/packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx index 7508e1839a2..2fbaf91b1ea 100644 --- a/packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx +++ b/packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx @@ -708,7 +708,14 @@ export class DiscreteBarChart let sortByFunc: (item: DiscreteBarItem) => number | string | undefined switch (this.sortConfig.sortBy) { case SortBy.custom: - sortByFunc = (): undefined => undefined + if (this.seriesStrategy === SeriesStrategy.entity) { + sortByFunc = (item: DiscreteBarItem): number => + this.selectionArray.selectedEntityNames.indexOf( + item.seriesName + ) + } else { + sortByFunc = (): undefined => undefined + } break case SortBy.entityName: sortByFunc = (item: DiscreteBarItem): string => item.seriesName