I needed to set up the AChartEngine library for Android in order to turn a pie chart into a donut chart. I needed to replace the following:
canvas.drawArc(oval, startAngle, sweepAngle, useCenter, paint);
using the Path class to be able to use cropping. The following code did the job for me:
Path path = new Path(); path.moveTo(oval.centerX(), oval.centerY()); path.addArc(oval, startAngle, sweepAngle); path.lineTo(oval.centerX(), oval.centerY()); canvas.drawPath(path, paint);
Hope this saves some headaches from people not familiar with the Canvas API like me.
source share