-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add Pattern Painters Support for BarChart (Stripes, Dots, Squares) #1958
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
Hi, thanks for your contribution. I really like the idea. |
Hi @imaNNeo, I managed to get the same result using FragmentShaders but I'm not sure how to test them. I'm working on it. |
Showcase with shadersSimulator.Screen.Recording.-.iPhone.16.Pro.-.2025-08-03.at.19.29.06.mp4 |
That looks amazing! 🤩
Please let me know what you think. |
Removed FlShaderManager and replaced patternPainter with surfacePainter in BarChartRodData. Refactored pattern painter classes to extend FlSurfacePainter, added initialization logic, and updated related usages and tests. Renamed fl_shader_painter.dart to fl_surface_painter.dart and updated exports. Added dedicated shader tests and removed obsolete manager tests.
Hi @imaNNeo, thanks for your feedback. I've made the changes you asked for. Let me know what you think about them. |
This PR introduces support for custom pattern painters in the
BarChart
component, allowing each bar to be rendered with a configurable pattern. The following features and improvements are included:CustomPainter
classes for bar patterns:StripesPatternPainter
: Draws diagonal, vertical, or horizontal stripes at a configurable angle.CirclePoisPatternPainter
: Draws a polka dot (circle) pattern.SquarePoisPatternPainter
: Draws a polka dot (square) pattern.BarChartRodData
now accepts apatternPainter
property. If set, the bar will be rendered using the provided pattern.bar_chart_sample1.dart
) to allow users to select and preview different bar patterns via a dropdown.Motivation
These changes make it easy to add visual variety to bar charts, supporting use cases such as accessibility, branding, and improved data distinction. The new pattern painters are fully customizable and integrate seamlessly with the existing chart API. Related to this issue.
Showcase
showcase_compressed.mp4