Repository navigation
fix: Skip zero-value sections in PieChart touch detection - #2116
Closed
ibrahim-iqbal wants to merge 1 commit into
Closed
ibrahim-iqbal wants to merge 1 commit into
ibrahim-iqbal wants to merge 1 commit into
Conversation
When sections have a value of 0, their sweep angle is 0 and the generated path is degenerate. Path.contains() can return unreliable results for such paths, causing the touched section index to be incorrect. Skip sections with a zero angle in the touch detection loop so only visible sections are considered touchable.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2116 +/- ##
=======================================
Coverage 94.13% 94.13%
=======================================
Files 54 54
Lines 4671 4672 +1
=======================================
+ Hits 4397 4398 +1
Misses 274 274
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1632
When
PieChartSectionDataentries have a value of0, their calculated sweep angle is0. ThegenerateSectionPathmethod produces a degenerate path for zero-angle sections, andPath.contains()can return unreliable results for such paths. This causes the touched section index to be incorrect when some sections have zero values.Example: Given values
[0, 0, 100, 200, 300], touching the section for value100(index 2) could incorrectly return index0.Changes
pie_chart_painter.dart: Skip sections withsectionAngle == 0inhandleTouch()so only visible sections are considered touchablepie_chart_painter_test.dart: Added test case with zero-value sections verifying correct touch detectionTest plan
flutter analyzereports no issues on changed filesdart formatreports no changes needed