Skip to content

feat: Add section offset to pie chart#2092

Open
jay-k98 wants to merge 3 commits intoimaNNeo:mainfrom
jay-k98:feature/pie-chart-section-offset
Open

feat: Add section offset to pie chart#2092
jay-k98 wants to merge 3 commits intoimaNNeo: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].

jay-k98 added 3 commits April 22, 2026 11:17
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
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.10%. Comparing base (15562ee) to head (e327e0e).

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              
Flag Coverage Δ
flutter 93.10% <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!

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