Skip to content

Conversation

@dtunikov
Copy link

@dtunikov dtunikov commented Dec 1, 2025

Summary

  • Add ability to control sorting of count-plot bars from the UI
  • New sortBy option: sort by total count ("all") or selected/filtered count ("sel")
  • New sortOrder option: ascending (↑) or descending (↓) order
  • Special values (null, other) remain at the bottom regardless of sort settings

Add ability to control sorting of count-plot bars from the UI:
- sortBy: sort by total count ("all") or selected/filtered count ("sel")
- sortOrder: ascending or descending order

Special values (null, other) remain at the bottom regardless of sort settings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@dtunikov
Copy link
Author

dtunikov commented Dec 1, 2025

Hi!

We have a use case where we want to sort entries in count-plot chart by the amount of entries matching current selection (in our case it's coming from applying a filter on chart1 and ordering the other charts accordingly)

Does it make sense?

@domoritz
Copy link
Member

domoritz commented Dec 1, 2025

Makes sense. Can you execute the test plan and carefully review the code since you used ai to generate it?

sortBy: "total" | "selected" | undefined,
sortOrder: "asc" | "desc" | undefined,
) {
// Split into regular items and special items (null, other)
Copy link
Member

Choose a reason for hiding this comment

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

This code iterates over the items two times. Would it be faster and simpler to use the special item index like before and then to use slice to split the array?

A unit test could also be good here.

Copy link
Author

Choose a reason for hiding this comment

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

added a test

@donghaoren
Copy link
Collaborator

We group items with smaller total count into the "(other)" category when there are too many distinct values. If we sort by count in selection, it will be possible that the top selected count is an item in the "(other)" category. The current code seems to sort after the SQL query, which means the "(other)" category is considered as a unit to sort. Is this what you intend, or do you intend to see the top item under "(other)"?

@dtunikov
Copy link
Author

dtunikov commented Jan 8, 2026

lemme know if smth else needs to be fixed
thanks

@donghaoren
Copy link
Collaborator

Thanks for the contribution! We are incorporating this as part of #136.

@donghaoren donghaoren closed this Jan 13, 2026
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.

3 participants