A pie chart is a circular chart divided into sectors. In a pie chart, the arc length of each sector is proportional to the quantity it represents. It is used to showcase different percentages of an entity distributed with time or any other parameter. For example it can be used to show Profit of a company distributed over 12 months of a year. Less profit means smaller arc for that month and vice-versa.

In I-Phone we might have a application which needs to showcase a Pie chart view for different kind of data. Suppose the application have option to show profit distribution over month, employee distribution over different centers, Projects delivered over different months and so on.
Obviously we would not like to make different classes for each and every Pie chart showing different kind of data e.g. one for profit and another for employee distribution and so on.

So here is a class which can handle all these data and will draw chart according to them.

3. The add detail function can be updated/changed according to the user requirement for showing the details about the different sections of Pie chart

4. To create a Pie chart now, we only need to make an object of the above class and set the desired parameters.

The following code can be written in any class which is pushing the view on the screen.

PieChartView* chartView = [[PieChartViewalloc] init];
[chartView setRadius:100RelativeCentreXaxis:0Yaxis:0];
//colorArray is a array having UIColor's for different sections.
//percentageArray holds the percentage of a section in Pie chart which would be proportional to the data in that period
//Both arrays can be filled using plist.
[chartView setColor: colorArray setPercentage: percentageArray];

5. Push the View on the screen.

6. For different type of distributions we now only need to change the colorArray and percentageArray.