In my last project I was spending a lot of time looking at charting/graphing libraries for Android. I finally found the awesome AChartEngine but found it very hard to get a simple example working. So here is now a small PieChart example which hopefully can get you started! This example shows a pie chart with income, costs and the difference in a “sub total” sum.
Here’s a quick how to:
- Extend GraphicalView (class in AChartEngine)
- Create a getNewInstance method that returns the current class using a custom Renderer and DataSet
- Create a custom Renderer (defines colors and labels for the chart)
- Create a custom DataSet (the data maps to the colors you give in the renderer)
To use this awesome PieChart you’ve now created you need to create a Layout in your xml which you can add the instance to.