-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add shadow for Pie Chart #1497
base: main
Are you sure you want to change the base?
Add shadow for Pie Chart #1497
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1497 +/- ##
=======================================
Coverage ? 85.34%
=======================================
Files ? 45
Lines ? 3078
Branches ? 0
=======================================
Hits ? 2627
Misses ? 451
Partials ? 0 ☔ View full report in Codecov by Sentry. |
It seems there is an issue, it freezes the app (tested on iPhone and macOS) |
Can you test again? I changed the number of layers to be drawn, it should fix this issue. |
Okay, I found the freeze issue, if you change the offset to Offset(0, 0), it freezes the app process (it seems a low-level exception happens) |
offset = offset ?? const Offset(3, 3), | ||
color = color ?? Colors.black.withOpacity(0.5), | ||
numberOfLayers = numberOfLayers ?? 1, | ||
minDarkenValue = minDarkenValue ?? 0, |
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.
Please define a better value for minDarkenValue and maxDarkenValue to simplify the usage. (for example 40 and 70 as you used in examples)
final bool show; | ||
final Offset offset; | ||
final Color color; | ||
final MaskFilter? maskFilter; |
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.
Do we need it for a simple shadow? If yes, please make it non-nullable and define a default value to make it simple for user/developer to implement a shadow
@@ -78,6 +78,79 @@ class FlBorderData with EquatableMixin { | |||
]; | |||
} | |||
|
|||
/// Holds data to drawing shdow for the 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.
Typo for shdow
@@ -78,6 +78,79 @@ class FlBorderData with EquatableMixin { | |||
]; | |||
} | |||
|
|||
/// Holds data to drawing shdow for the chart. | |||
class FlShadowData with EquatableMixin { | |||
/// [show] Determines showing or hiding border around the 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.
hiding border is wrong. It should be hiding shadow I think
maxDarkenValue == null || | ||
maxDarkenValue >= minDarkenValue, | ||
); | ||
final bool show; |
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.
Please write the code doc for the properties.
|
||
bool isVisible() => show; | ||
|
||
/// Copies current [FlBorderData] to a new [FlBorderData], |
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.
FlBorderData is wrong here
@@ -213,6 +214,8 @@ class PieChartSectionData { | |||
/// 1.0 means near the outside of the [PieChart]. | |||
final double badgePositionPercentageOffset; | |||
|
|||
final FlShadowData? shadow; |
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.
Write the code doc please
@@ -268,6 +273,7 @@ class PieChartSectionData { | |||
b.badgePositionPercentageOffset, | |||
t, | |||
), | |||
shadow: b.shadow, |
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 have a FlShadowData.lerp()
here? It makes it good when animating between states.
Please update the pie_chart.md and base_chart.md docs. |
break; | ||
} | ||
|
||
final sectionPath = generateSectionPath( |
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.
Please store this variable in the outer scope to make it possible to re-use it on line 168 when we want to draw actual paths to improve the performance.
offset: offset ?? this.offset, | ||
color: color ?? this.color, | ||
maskFilter: maskFilter ?? this.maskFilter, | ||
numberOfLayers: numberOfLayers ?? 1, |
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.
You need to use this.numberOfLayers
instead of hard-coded 1
color: color ?? this.color, | ||
maskFilter: maskFilter ?? this.maskFilter, | ||
numberOfLayers: numberOfLayers ?? 1, | ||
minDarkenValue: minDarkenValue ?? 0, |
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.
You need to use this.minDarkenValue
instead of hard-coded 0
maskFilter: maskFilter ?? this.maskFilter, | ||
numberOfLayers: numberOfLayers ?? 1, | ||
minDarkenValue: minDarkenValue ?? 0, | ||
maxDarkenValue: maxDarkenValue ?? 0, |
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.
You need to use this.maxDarkenValue
instead of hard-coded 0
This adds the drop shadow to the Pie Chart with some cool customizations
You can add simply a drop shadow like this (check the pie chart sample 4 here)
Also you can simulate the third dimension like this (check the pie chart sample 5 here)
solves #1482