From efc1744dda30d6d32fc6f78f963f519e44c94045 Mon Sep 17 00:00:00 2001 From: Usama Ansari Date: Wed, 18 Dec 2024 12:01:27 +0100 Subject: [PATCH] chore: add sorting to the facets --- src/vis/bar/BarChart.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vis/bar/BarChart.tsx b/src/vis/bar/BarChart.tsx index 999bfa7b9..5b51b7963 100644 --- a/src/vis/bar/BarChart.tsx +++ b/src/vis/bar/BarChart.tsx @@ -109,7 +109,7 @@ export function BarChart({ const set = new Set(); barData?.facetsColVals?.resolvedValues.forEach((v) => set.add(getLabelOrUnknown(v.val))); const uniqueFacetValues = [...set] as string[]; - return uniqueFacetValues.sort((a, b) => (a === NAN_REPLACEMENT || b === NAN_REPLACEMENT ? 1 : a && b ? a.localeCompare(b) : 0)); + return uniqueFacetValues.sort((a, b) => (a === NAN_REPLACEMENT ? 1 : b === NAN_REPLACEMENT ? -1 : a && b ? a.localeCompare(b) : 0)); }, [barData?.facetsColVals?.resolvedValues]); const filteredUniqueFacetVals = React.useMemo(() => { @@ -117,7 +117,7 @@ export function BarChart({ typeof config?.focusFacetIndex === 'number' && config?.focusFacetIndex < allUniqueFacetVals.length ? ([allUniqueFacetVals[config?.focusFacetIndex]] as string[]) : allUniqueFacetVals; - return unsorted.sort((a, b) => (a === NAN_REPLACEMENT || b === NAN_REPLACEMENT ? 1 : a && b ? a.localeCompare(b) : 0)); + return unsorted.sort((a, b) => (a === NAN_REPLACEMENT ? 1 : b === NAN_REPLACEMENT ? -1 : a && b ? a.localeCompare(b) : 0)); }, [allUniqueFacetVals, config?.focusFacetIndex]); const groupColorScale = React.useMemo(() => {