Skip to content

Commit 2e80fad

Browse files
committed
Fixed a bug where the mod-360 bypass draws a full-circle for 0 slices.
1 parent 4cb83a7 commit 2e80fad

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ protected void drawDataSet(Canvas c, IPieDataSet dataSet) {
269269
float arcStartPointX = center.x + radius * (float) Math.cos(startAngleOuter * Utils.FDEG2RAD);
270270
float arcStartPointY = center.y + radius * (float) Math.sin(startAngleOuter * Utils.FDEG2RAD);
271271

272-
if (sweepAngleOuter % 360f <= Utils.FLOAT_EPSILON) {
272+
if (sweepAngleOuter >= 360.f && sweepAngleOuter % 360f <= Utils.FLOAT_EPSILON) {
273273
// Android is doing "mod 360"
274274
mPathBuffer.addCircle(center.x, center.y, radius, Path.Direction.CW);
275275
} else {
@@ -318,7 +318,7 @@ protected void drawDataSet(Canvas c, IPieDataSet dataSet) {
318318
}
319319
final float endAngleInner = startAngleInner + sweepAngleInner;
320320

321-
if (sweepAngleOuter % 360f == 0.f) {
321+
if (sweepAngleOuter >= 360.f && sweepAngleOuter % 360f <= Utils.FLOAT_EPSILON) {
322322
// Android is doing "mod 360"
323323
mPathBuffer.addCircle(center.x, center.y, innerRadius, Path.Direction.CCW);
324324
} else {
@@ -335,7 +335,7 @@ protected void drawDataSet(Canvas c, IPieDataSet dataSet) {
335335
}
336336
} else {
337337

338-
if (sweepAngleOuter % 360f != 0.f) {
338+
if (sweepAngleOuter % 360f > Utils.FLOAT_EPSILON) {
339339
if (accountForSliceSpacing) {
340340

341341
float angleMiddle = startAngleOuter + sweepAngleOuter / 2.f;
@@ -818,7 +818,7 @@ public void drawHighlighted(Canvas c, Highlight[] indices) {
818818

819819
mPathBuffer.reset();
820820

821-
if (sweepAngleOuter % 360f == 0.f) {
821+
if (sweepAngleOuter >= 360.f && sweepAngleOuter % 360f <= Utils.FLOAT_EPSILON) {
822822
// Android is doing "mod 360"
823823
mPathBuffer.addCircle(center.x, center.y, highlightedRadius, Path.Direction.CW);
824824
} else {
@@ -875,7 +875,7 @@ public void drawHighlighted(Canvas c, Highlight[] indices) {
875875
}
876876
final float endAngleInner = startAngleInner + sweepAngleInner;
877877

878-
if (sweepAngleOuter % 360f == 0.f) {
878+
if (sweepAngleOuter >= 360.f && sweepAngleOuter % 360f <= Utils.FLOAT_EPSILON) {
879879
// Android is doing "mod 360"
880880
mPathBuffer.addCircle(center.x, center.y, innerRadius, Path.Direction.CCW);
881881
} else {
@@ -892,7 +892,7 @@ public void drawHighlighted(Canvas c, Highlight[] indices) {
892892
}
893893
} else {
894894

895-
if (sweepAngleOuter % 360f != 0.f) {
895+
if (sweepAngleOuter % 360f > Utils.FLOAT_EPSILON) {
896896

897897
if (accountForSliceSpacing) {
898898
final float angleMiddle = startAngleOuter + sweepAngleOuter / 2.f;

0 commit comments

Comments
 (0)