- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.9k
Add shrink wrap for bar chart when overflow #1953
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
When shrinkWrapOnWidthOverflow is set to true, the first and last bars in the chart should be touching the sides instead of having space at the start/end. The bars should still be spaced evenly. Fixes imaNNeo#1952
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 adds a new feature to allow bar charts to shrink wrap when content would overflow, making the first and last bars touch the container edges instead of having padding. This resolves issue #1952 by providing better space utilization when chart content exceeds available width.
Key changes:
- Added shrinkWrapOnWidthOverflowboolean property toBarChartData
- Modified spacing logic to eliminate edge padding when shrink wrap is enabled
- Updated data class methods to support the new property
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description | 
|---|---|
| lib/src/chart/bar_chart/bar_chart_data.dart | Adds the new shrinkWrapOnWidthOverflowboolean property to the data model with proper constructor, copyWith, and lerp support | 
| lib/src/extensions/bar_chart_data_extension.dart | Implements the spacing logic to conditionally remove edge spacing when shrink wrap is enabled | 
| I have pushed changes to address the Copilot code review 😊 | 
| Does it matter what type of Alignment we're using for  | 
| Hi 👋 I have added the property into  As for your question: The  This case happens when  This can be seen in  Please let me know if there are any other issues 😊 | 
| Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@           Coverage Diff           @@
##             main    #1953   +/-   ##
=======================================
  Coverage        ?   92.52%           
=======================================
  Files           ?       50           
  Lines           ?     3717           
  Branches        ?        0           
=======================================
  Hits            ?     3439           
  Misses          ?      278           
  Partials        ?        0           
 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
| I added a test that should make for 100% coverage now 😊 | 
| To be honest, I don't see this flag as the fix to the bug that happens when you define  What do you think? | 
| Yeah, that makes sense if it just automatically applies if there would be overflow, rather than setting the property manually. My thought was that some people might not want the bars to touch the edge so having a property to alter the behaviour when there is an overflow accounted for that. But for ease-of-use, I think you're right it's better to let it get worked out behind the scenes when there is an overflow, and users can calculate the appropriate spacing based on their container size if they want to avoid the overflow behaviour. I will update it 😊 | 
| Is that what you had in mind? 😊 | 
This pull request is to resolve #1952.
This should allow the user to set a property to make the first and last bars touch the sides of the container when they would otherwise overflow and get auto-spaced (in
spaceEvenly()).When
shrinkWrapOnWidthOverflowis set totrue, the first and last bars in the chart should be touching the sides instead of having space at the start/end.The bars should still be spaced evenly.
Checklist
Screenshots:
With

shrinkWrapOnWidthOverflow = true:With

shrinkWrapOnWidthOverflow = false: