-
-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: Add stroke support for LineChartBarData #2076
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,6 +281,18 @@ class LineChartPainter extends AxisChartPainter<LineChartData> { | |
| barData, | ||
| ); | ||
| drawBarShadow(canvasWrapper, barPath, barData); | ||
| if (barData.strokeColor != null && barData.strokeWidth > 0) { | ||
| final borderPaint = Paint() | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a performance issue with creating the Paint() object in every frame. |
||
| ..color = barData.strokeColor! | ||
| ..strokeWidth = barData.barWidth + (barData.strokeWidth * 2) | ||
| ..style = PaintingStyle.stroke | ||
| ..strokeCap = | ||
| barData.isStrokeCapRound ? StrokeCap.round : StrokeCap.butt | ||
| ..strokeJoin = | ||
| barData.isStrokeJoinRound ? StrokeJoin.round : StrokeJoin.miter; | ||
|
|
||
| canvasWrapper.canvas.drawPath(barPath, borderPaint); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line bypasses the canvas wrapper. All drawing must go through canvasWrapper.drawPath(...) So please use |
||
| } | ||
| drawBar(canvasWrapper, barPath, barData, holder); | ||
| } | ||
| } | ||
|
|
||
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.
Can we use the BorderSide class instead of defining strokeColor and strokeWidth here?
Because all other chart types in fl_chart use BorderSide for borders (e.g., BarChartRodData.borderSide, PieChartSectionData.borderSide).
Let's keep the API consistent: