diff --git a/piechart/src/androidTest/assets/screenshot-72.png b/piechart/src/androidTest/assets/screenshot-72.png new file mode 100644 index 00000000..cae54c96 Binary files /dev/null and b/piechart/src/androidTest/assets/screenshot-72.png differ diff --git a/piechart/src/androidTest/kotlin/ir/mahozad/android/ScreenshotTest.kt b/piechart/src/androidTest/kotlin/ir/mahozad/android/ScreenshotTest.kt index 6ccd22ff..f37b9e04 100644 --- a/piechart/src/androidTest/kotlin/ir/mahozad/android/ScreenshotTest.kt +++ b/piechart/src/androidTest/kotlin/ir/mahozad/android/ScreenshotTest.kt @@ -596,6 +596,12 @@ class ScreenshotTest { } } + @Test fun chartWithASingleSlice() { + compareScreenshots("screenshot-72") { + slices = listOf(Slice(1f, Color.rgb(133, 77, 206))) + } + } + /** * FIXME: the name of the function is misleading. It also works in a saving * mode in that it just saves the screenshot on device and skips the comparison. diff --git a/piechart/src/main/kotlin/ir/mahozad/android/component/Pie.kt b/piechart/src/main/kotlin/ir/mahozad/android/component/Pie.kt index ec8bc36f..fb6975e3 100644 --- a/piechart/src/main/kotlin/ir/mahozad/android/component/Pie.kt +++ b/piechart/src/main/kotlin/ir/mahozad/android/component/Pie.kt @@ -144,7 +144,11 @@ internal class Pie( mainPaint.shader = gradient mainPaint.alpha = 255 - val slicePath = makeSlice(center, pieEnclosingRect, currentAngle, slice.fraction, pieDrawDirection, slice.pointer ?: slicesPointer) + val slicePath = if (slice.fraction == 1f) { + Path().apply { addCircle(center.x, center.y, radius, Path.Direction.CW) } + } else { + makeSlice(center, pieEnclosingRect, currentAngle, slice.fraction, pieDrawDirection, slice.pointer ?: slicesPointer) + } canvas.withClip(clip) { canvas.drawPath(slicePath, mainPaint) }