Reputation: 1217
I need to draw the Pie Chart Manually .I need some basic Ideas to do that.Can anyone help Me ??
Upvotes: 0
Views: 2455
Reputation: 1258
I've created a library to do what you are looking for (https://github.com/saulpower/ExpandablePieChart).
Upvotes: 0
Reputation: 1252
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DemoView demoView=new DemoView(getBaseContext());
setContentView(demoView);
}
private class DemoView extends View{
public DemoView(Context context){
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
RectF mBigOval = new RectF(40, 10, 280, 250);
Paint p = new Paint();
DashPathEffect dashPath = new DashPathEffect(new float[]{5,5}, (float)1.0);
PathEffect path=new PathEffect();
p.setPathEffect(path);
p.setStyle(Style.FILL_AND_STROKE);
p.setColor(android.graphics.Color.GREEN);
canvas.drawArc(mBigOval, 0, 360, true, p);
p.setColor(Color.RED);
canvas.drawArc(mBigOval, 0, 240, true, p);
invalidate();
}
}
try this code
Upvotes: 3
Reputation: 54475
Create your own custom View
class and implement the onDraw
method to draw the chart using ArcShape
.
You can then include your chart component in a layout just as you would one of the built-in components.
Upvotes: 0
Reputation: 104178
Here is an example in Java (not for Android). You could easily port it for Android by using a Canvas instead of Graphics2D object. Instead of fillArc for example, you would use drawArc.
Upvotes: 0