-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Summary
The ChartView bar chart currently hardcodes sorting by count descending (highest to lowest) via sortCategoryValueViewsCount. We want to allow configuring the sort order per chart.
Current Behavior
In usePlotOptions hook (src/components/Index/components/EntityView/components/views/ChartView/components/Chart/hooks/UsePlotOptions/hook.ts), bars are always sorted by:
.sort(sortCategoryValueViewsCount) // count descending, alpha tiebreakerDesired Behavior
Allow configuring the chart sort order via SelectCategoryConfig. The codebase already has sort infrastructure in src/common/filters/sort/ with:
FILTER_SORTenum (ALPHA,COUNT)sortCategoryValueViewsAlpha— alphabetical (case-insensitive)sortCategoryValueViewsCount— count descending with alpha tiebreaker
Suggested Approach
Add a chartSort option to SelectCategoryConfig (or introduce a new enum like CHART_SORT) that supports at minimum:
- COUNT (default, current behavior) — count descending
- ALPHA — alphabetical ascending by label
The enum-based approach is preferred over a custom sort function because:
- The sort functions and enum pattern already exist in
src/common/filters/sort/ - Only two meaningful sort dimensions exist (count and label)
- Keeps the config serializable and simple
Key files
| File | Role |
|---|---|
src/common/filters/sort/config/types.ts |
Existing FILTER_SORT enum |
src/common/filters/sort/models/utils.ts |
Existing sort functions |
src/common/categories/config/types.ts |
SelectCategoryConfig — add chartSort here |
src/components/.../ChartView/components/Chart/hooks/UsePlotOptions/hook.ts |
Where sort is applied — parameterize here |
src/components/.../ChartView/components/Chart/types.ts |
ChartProps — thread sort config through |
Default should remain COUNT for backward compatibility.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels