Skip to content

feat: Add section offset to pie chart#2092

Open
jay-k98 wants to merge 4 commits into
imaNNeo:mainfrom
jay-k98:feature/pie-chart-section-offset
Open

feat: Add section offset to pie chart#2092
jay-k98 wants to merge 4 commits into
imaNNeo:mainfrom
jay-k98:feature/pie-chart-section-offset

Conversation

@jay-k98
Copy link
Copy Markdown
Contributor

@jay-k98 jay-k98 commented Apr 22, 2026

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].

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (a9147f0) to head (83d2fc5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2092      +/-   ##
==========================================
+ Coverage   94.13%   94.16%   +0.02%     
==========================================
  Files          54       54              
  Lines        4675     4694      +19     
==========================================
+ Hits         4401     4420      +19     
  Misses        274      274              
Flag Coverage Δ
flutter 94.16% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

final sectionCenterAngle = startAngle + (sweepAngle / 2);
final centerRadius = calculateCenterRadius(viewSize, holder);

final sectionOffset = section.sectionOffset;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@imaNNeo
Copy link
Copy Markdown
Owner

imaNNeo commented Apr 28, 2026

Please fix those 3 comments. After that we're good to go!

jay-k98 added 3 commits May 13, 2026 14:29
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>
@jay-k98 jay-k98 force-pushed the feature/pie-chart-section-offset branch from e327e0e to d2f43fb Compare May 13, 2026 13:29
Signed-off-by: Jonas Klock <jonas.klock@exxeta.com>
@jay-k98 jay-k98 force-pushed the feature/pie-chart-section-offset branch from d2f43fb to 83d2fc5 Compare May 13, 2026 13:49
@jay-k98
Copy link
Copy Markdown
Contributor Author

jay-k98 commented May 13, 2026

Hi @imaNNeo Thanks for the feedback and yes I agree with you. I updated the branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants