Skip to content

feat!: chartview: add configurable bar sort order (#772)#773

Merged
NoopDog merged 4 commits intomainfrom
fran/772-bar-sort
Feb 17, 2026
Merged

feat!: chartview: add configurable bar sort order (#772)#773
NoopDog merged 4 commits intomainfrom
fran/772-bar-sort

Conversation

@frano-m
Copy link
Contributor

@frano-m frano-m commented Feb 17, 2026

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 Chart configuration 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

  • Replaced the enableChartView boolean with a chart object in SelectCategoryView, 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]
  • Introduced chart sorting types (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]
  • Added getChartSortFn utility 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)
  • Updated the ChartView component 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]
  • Adjusted filtering logic to use the new chart.enable property 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

  • Added comprehensive tests for chart sorting utilities, including mapping, default behavior, custom functions, and integration scenarios. (tests/chartSortUtils.test.ts, tests/chartSortUtils.test.tsR1-R119)
  • Updated chart and chart view story args to use the new chart configuration 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

  • Removed redundant sorting from the usePlotOptions hook, 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.

image image image

frano-m and others added 4 commits February 17, 2026 11:13
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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 enableChartView boolean with a Chart configuration object containing enable and optional sortBy properties
  • Introduced chart sorting infrastructure with CHART_SORT enum (ALPHA, COUNT), sort function types, and a utility to resolve sort options to functions
  • Moved chart data sorting from usePlotOptions hook to upstream in ChartView component, 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 NoopDog merged commit bea776a into main Feb 17, 2026
8 checks passed
@frano-m frano-m deleted the fran/772-bar-sort branch February 17, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChartView: Add configurable bar sort order

3 participants