From eff335f1e34fe2a4f32533706311b38388ea1f37 Mon Sep 17 00:00:00 2001 From: Usama Ansari Date: Wed, 18 Dec 2024 11:52:55 +0100 Subject: [PATCH] chore: add sorting to the facets --- src/vis/bar/BarChart.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vis/bar/BarChart.tsx b/src/vis/bar/BarChart.tsx index 09f9e890a..999bfa7b9 100644 --- a/src/vis/bar/BarChart.tsx +++ b/src/vis/bar/BarChart.tsx @@ -108,7 +108,8 @@ export function BarChart({ const allUniqueFacetVals = React.useMemo(() => { const set = new Set(); barData?.facetsColVals?.resolvedValues.forEach((v) => set.add(getLabelOrUnknown(v.val))); - return [...set] as string[]; + const uniqueFacetValues = [...set] as string[]; + return uniqueFacetValues.sort((a, b) => (a === NAN_REPLACEMENT || b === NAN_REPLACEMENT ? 1 : a && b ? a.localeCompare(b) : 0)); }, [barData?.facetsColVals?.resolvedValues]); const filteredUniqueFacetVals = React.useMemo(() => {