feat!: chartview: add configurable bar sort order (#772)#773
Merged
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request introduces a flexible and extensible chart sorting system for select category charts, replacing the previous boolean enableChartView flag with a comprehensive Chart configuration object. The changes enable configurable sorting options (alphabetical, count-based, or custom functions) for chart bars while maintaining backward compatibility.
Changes:
- Replaced
enableChartViewboolean with aChartconfiguration object containingenableand optionalsortByproperties - Introduced chart sorting infrastructure with
CHART_SORTenum (ALPHA, COUNT), sort function types, and a utility to resolve sort options to functions - Moved chart data sorting from
usePlotOptionshook to upstream inChartViewcomponent, where it applies the configured sort before rendering - Added comprehensive test coverage for sorting utilities and integration scenarios
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/common/chart/types.ts |
New Chart interface with enable and sortBy properties |
src/common/chart/sort/types.ts |
Chart sorting types and enum (ALPHA, COUNT) with support for custom functions |
src/common/chart/sort/constants.ts |
Mapping from CHART_SORT enum to sort functions |
src/common/chart/sort/utils.ts |
Utility function to resolve sort options, defaulting to COUNT |
src/common/entities.ts |
Updated SelectCategoryView to use optional Chart instead of enableChartView |
src/common/categories/config/types.ts |
Updated SelectCategoryConfig with chart property |
src/hooks/useCategoryFilter.ts |
Maps chart config from SelectCategoryConfig to view |
src/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/utils.ts |
Sets chart to undefined for TanStack adapter views |
src/components/Index/components/EntityView/components/views/ChartView/chartView.tsx |
Applies chart sorting before rendering |
src/components/Index/components/EntityView/components/views/ChartView/utils.ts |
Updated filter logic from enableChartView to chart?.enable !== false |
src/components/Index/components/EntityView/components/views/ChartView/components/Chart/hooks/UsePlotOptions/hook.ts |
Removed redundant sorting logic |
src/components/Index/components/EntityView/components/views/ChartView/stories/args.ts |
Updated story args to use new chart configuration |
src/components/Index/components/EntityView/components/views/ChartView/components/Chart/stories/args.ts |
Reordered test data for consistency |
tests/chartSortUtils.test.ts |
Comprehensive test suite for chart sorting utilities |
.gitignore |
Added .claude configuration files (unrelated to feature) |
NoopDog
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #772.
This pull request introduces a flexible and extensible chart sorting system for select category charts. The main changes include replacing the previous boolean chart view flag with a new
Chartconfiguration object, adding support for customizable sorting options, and updating relevant components and utilities to use this new configuration. Comprehensive tests have also been added to verify sorting logic.Chart configuration and sorting enhancements
enableChartViewboolean with achartobject inSelectCategoryView,SelectCategoryConfig, and related interfaces, allowing charts to be enabled/disabled and sorted using customizable options. (src/common/categories/config/types.ts,src/common/entities.ts,src/components/Filter/components/adapters/tanstack/ColumnFiltersAdapter/utils.ts,src/hooks/useCategoryFilter.ts, [1] [2] [3] [4] [5]CHART_SORT,ChartSortFn,ChartSortOptions) and a mapping from sort options to sort functions. (src/common/chart/sort/types.ts,src/common/chart/sort/constants.ts, [1] [2]getChartSortFnutility to resolve chart sort options to the correct sorting function, defaulting to count sort if not specified. (src/common/chart/sort/utils.ts, src/common/chart/sort/utils.tsR1-R22)ChartViewcomponent to use the new chart sort configuration, sorting values according to the specified option. (src/components/Index/components/EntityView/components/views/ChartView/chartView.tsx, [1] [2]chart.enableproperty instead of the old flag. (src/components/Index/components/EntityView/components/views/ChartView/utils.ts, src/components/Index/components/EntityView/components/views/ChartView/utils.tsL16-R16)Testing and story updates
tests/chartSortUtils.test.ts, tests/chartSortUtils.test.tsR1-R119)chartconfiguration and ensure consistent ordering of test data. (src/components/Index/components/EntityView/components/views/ChartView/components/Chart/stories/args.ts, [1] [2] [3] [4];src/components/Index/components/EntityView/components/views/ChartView/stories/args.ts, [5] [6] [7]Refactoring and cleanup
usePlotOptionshook, as sorting is now handled upstream. (src/components/Index/components/EntityView/components/views/ChartView/components/Chart/hooks/UsePlotOptions/hook.ts, [1] [2]These changes make chart sorting more flexible, support custom sorting functions, and improve maintainability and test coverage.