Reputation: 1252
How can i draw an animated pie-chart? I have drawn a chart and below is the code. I now need the chart to become animated when it gets loaded on to the screen. How can I achieve this and can anyone give me an idea of what I should look for or where?
Upvotes: 2
Views: 3922
Reputation: 127
I made small example. maybe it be helpful for you. Animated pie char. The implementation was based on the SurfaceView. In SurfaceView I set thread. This thread calculate animation with 60 FPS.
long ticksPS = 1000 / 60;
long startTime;
long sleepTime;
while (running) {
sleepTime = ticksPS-(System.currentTimeMillis() - startTime);
try {
if (sleepTime > 0)
Thread.sleep(sleepTime);
else
Thread.sleep(10);
} catch (Exception e) {}
}
Rendering by using the method canvas.drawArc. Each frame increases sweepAngle.
if((sweepAngle+startAngle) <= endAngle){
sweepAngle+=2;
}
For more details you can see on github.
Upvotes: 3