feat: Add section offset to pie chart#2092
Conversation
Signed-off-by: Jonas Klock <jonas.klock@exxeta.com>
Signed-off-by: Jonas Klock <jonas.klock@exxeta.com>
Signed-off-by: Jonas Klock <jonas.klock@exxeta.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2092 +/- ##
==========================================
+ Coverage 93.07% 93.10% +0.02%
==========================================
Files 50 50
Lines 3956 3972 +16
==========================================
+ Hits 3682 3698 +16
Misses 274 274
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:
|
| final sectionCenterAngle = startAngle + (sweepAngle / 2); | ||
| final centerRadius = calculateCenterRadius(viewSize, holder); | ||
|
|
||
| final sectionOffset = section.sectionOffset; |
There was a problem hiding this comment.
This logic of calculating offset is repeated multiple times in this file.
Can we just have a private shared function / getter for that instead of repeating it?
|
|
||
| /// Additional radial translation applied to the whole section (in logical pixels). | ||
| /// Positive values move the section outward along its center angle. | ||
| final double sectionOffset; |
There was a problem hiding this comment.
What do you think if we rename this new property to something like radialOffset?
Because commonly, we use the offset name for x and y in this project.
| tempAngle, | ||
| sectionAngle, | ||
| center, | ||
| center.translate(offsetDx, offsetDy), |
There was a problem hiding this comment.
And there's an issue with our rendering when we only show a single section (360 degrees).
I don't know what's the best way to handle it (as it is an edge case), but I think ignoring it is just fine!
But please explain it in the docs that if there's only one section (360 degrees), this parameter is ignored.
radialOffset.mov
|
Please fix those 3 comments. After that we're good to go! |
This Pull Request aims to implement the requested "exploding" pie chart sections of #2091.
Solution
Adding a [sectionOffset] parameter to [PieChartSectionData] and use that to calculate the offset in [drawSections] of [PieChartPainter].