-
Notifications
You must be signed in to change notification settings - Fork 789
add categories subtext and add min-width for each bar #7042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
||
| return ( | ||
| <div className="flex flex-col whitespace-pre -mt-1.5"> | ||
| <span>categories: {prettyNumber(stats.unique, locale)}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe unique over categories? i don't always think of each item as a category
| case "string": { | ||
| const lessThan5Categories = | ||
| typeof stats.unique === "number" && stats.unique <= 5; | ||
| // Number of categories will be easily visible from the chart, so don't show it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think its that easy to parse number of unique values, i would have to count each bar chart
There was a problem hiding this 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 PR enhances the table column summary feature by adding an others_threshold parameter to filter out low-count values and improve UI presentation of categorical data.
Key changes:
- Added
others_thresholdparameter to_get_value_counts()method to filter values with counts below a threshold - Improved frontend display logic to hide redundant category counts when there are 5 or fewer categories with charts
- Enhanced bar chart visualization with minimum bar width enforcement to improve visibility of small-count categories
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| marimo/_plugins/ui/_impl/table.py | Added others_threshold parameter to _get_value_counts() method to enable filtering values by count threshold |
| tests/_plugins/ui/_impl/test_table.py | Added test coverage for the new others_threshold parameter functionality |
| frontend/src/components/data-table/column-summary/column-summary.tsx | Conditionally hide category count text when ≤5 categories and chart is shown, plus added negative margin styling |
| frontend/src/components/data-table/column-summary/chart-spec-model.tsx | Implemented proportional bar width adjustment algorithm to ensure minimum 2% width for visibility of small bars |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| others_threshold (int | None): The threshold for values to be considered 'others'. | ||
| If a value has a count less than or equal to this threshold, it will be considered 'others'. |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The documentation states values with counts 'less than or equal to' the threshold are filtered, but the implementation at line 1089 only checks count <= others_threshold. This is correct, but the documentation could be clearer. Consider rephrasing to: 'The threshold for filtering values into others. Values with counts at or below this threshold will be excluded from the individual value list and grouped into others.'
| others_threshold (int | None): The threshold for values to be considered 'others'. | |
| If a value has a count less than or equal to this threshold, it will be considered 'others'. | |
| others_threshold (int | None): The threshold for filtering values into others. | |
| Values with counts at or below this threshold will be excluded from the individual value list and grouped into others. |
|
|
||
| // Calculate xStart and xEnd for each value count | ||
| // Adjust bar widths to ensure minimum width | ||
| const MIN_BAR_WIDTH_PERCENT = 0.02; // 2% minimum width |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The magic number 0.02 should be defined as a named constant at the module or class level for better maintainability and reusability. Consider defining it as const MIN_BAR_WIDTH_PERCENT = 0.02 outside the function scope.
📝 Summary
categories: numberas subtext for string chartsif

show_column_summaries="stats"🔍 Description of Changes
📋 Checklist