Added pie charts

4 views
Skip to first unread message

Brad Larson

unread,
Jan 12, 2010, 1:13:51 AM1/12/10
to coreplot...@googlegroups.com
I just added a rudimentary pie chart implementation in CPPieChart, based on suggestions by Cocan Lucian. It's very similar to the existing CPBarChart class, using delegate methods to provide fills for each slice of the pie:

-(CPFill *)sliceFillForPieChart:(CPPieChart *)pieChart recordIndex:(NSUInteger)index;

and labels for each slice:

-(CPTextLayer *)sliceLabelForPieChart:(CPPieChart *)pieChart recordIndex:(NSUInteger)index;

When supplying numerical values to the pie chart, it will sum up the values and normalize them such that the whole pie is 1.0. It will then draw an arc for the relative portion each value occupies in the whole. Slices currently are drawn clockwise in the order in which they are provided to the chart, with the first slice having its starting edge be pointing vertically upward.

An example of this new class can be found in the iPhone test application: http://twitpic.com/xrh8n

Cocoa bindings support is incomplete, and labeling is currently missing, so there's still quite a bit to finish here. It's a start, though.

______________________
Brad Larson, Ph.D.
Sunset Lake Software
http://www.sunsetlakesoftware.com

Ernest Prabhakar

unread,
Jan 12, 2010, 1:19:37 AM1/12/10
to coreplot...@googlegroups.com
An excellent start -- great work!

Drew McCormack

unread,
Jan 12, 2010, 3:25:05 AM1/12/10
to coreplot...@googlegroups.com
Yeah, good work Brad!

> --
> You received this message because you are subscribed to the Google Groups "coreplot-discuss" group.
> To post to this group, send email to coreplot...@googlegroups.com.
> To unsubscribe from this group, send email to coreplot-discu...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/coreplot-discuss?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages