halfhp / androidplot

Charts and plots for Android
http://androidplot.com
Apache License 2.0
503 stars 158 forks source link

Pie chart are not clickable with large segment #118

Open messenger63 opened 1 year ago

messenger63 commented 1 year ago

Hi, there is issue with Pie Chart. Steps to reproduce:

Seems like this issue happens when you have large segment, single segment more than 180deg, then part of that segment at the beginning are not clickable.

Please, reply if this issue could be fixed in near future.

messenger63 commented 1 year ago

The issue is in calculating dist at PieRenderer.getContainingSegment() Probably it should be something like this:

double dist = signedDistance(offset, angle); double endDist = signedDistance(offset, lastOffset); if (dist < 0) { // added dist = FULL_PIE_DEGS + dist; // added } // added if(endDist < 0) { // segment accounts for more than 50% of the pie and wrapped around // need to correct: endDist = FULL_PIE_DEGS + endDist; } Or some fix for signedDistance() method calculations.