Skip to content

Commit

Permalink
chore: add sorting to the facets
Browse files Browse the repository at this point in the history
  • Loading branch information
dv-usama-ansari committed Dec 18, 2024
1 parent eff335f commit efc1744
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vis/bar/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ 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(() => {
const unsorted =
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(() => {
Expand Down

0 comments on commit efc1744

Please sign in to comment.