Skip to content
A simple and animated Pie Chart for your iOS app.
Objective-C Ruby
Branch: master
Clone or download
Latest commit fb009d1 Nov 11, 2013
Type Name Latest commit message Commit time
Failed to load latest commit information.
Demo fixed selection notification, contributed by Jul 17, 2013
XYPieChart When compiling with the latest Xcode 5 preview 3 I got the following … Jul 17, 2013
.gitignore add gitignore Jun 12, 2012
LICENSE.txt re-edited Readme Mar 7, 2012
README.textile fix image path Nov 11, 2013
XYPieChart.podspec update podspec Sep 16, 2013



XYPieChart is an simple and easy-to-use pie chart for iOS app. It started from a Potion Project which needs an animated pie graph without interaction. All animation was implemented in the drawRect: method. After played with BTSPieChart, really like its code structure, it’s clean, has well named functions, structure like a UITableView. XYPieChart rewrote the code, based on CALayers for the animation. Compared to BTSPieChart, XYPieChart is a prettier version, it has a simpler insert/delete slices algorithm, different design of slice selection, more flexible to customize. Video Demo


  • Customized color for slices (default color supported)
  • animated insert/delete slice(s)
  • slice selection animation
  • text label option of showing percentage or actual value
  • text label auto-hide when slice is too small
  • customizable text label font and relative postion
  • pie opening/closing animation
  • pie starting angle support
  • ARC support
  • interface builder support


  • Drag the XYPieChart/XYPieChart folder into your project.
  • Add the QuartzCore framework to your project.


(see sample Xcode project in /Demo)

Set PieChart properties:

[self.pieChart setDelegate:self];
[self.pieChart setDataSource:self];
[self.pieChart setStartPieAngle:M_PI_2];	//optional
[self.pieChart setAnimationSpeed:1.0];	//optional
[self.pieChart setLabelFont:[UIFont fontWithName:@"DBLCDTempBlack" size:24]];	//optional
[self.pieChart setLabelColor:[UIColor blackColor]];	//optional, defaults to white
[self.pieChart setLabelShadowColor:[UIColor blackColor]];	//optional, defaults to none (nil)
[self.pieChart setLabelRadius:160];	//optional
[self.pieChart setShowPercentage:YES];	//optional
[self.pieChart setPieBackgroundColor:[UIColor colorWithWhite:0.95 alpha:1]];	//optional
[self.pieChart setPieCenter:CGPointMake(240, 240)];	//optional

Implement Data Source Methods:

- (NSUInteger)numberOfSlicesInPieChart:(XYPieChart *)pieChart;
- (CGFloat)pieChart:(XYPieChart *)pieChart valueForSliceAtIndex:(NSUInteger)index;
- (UIColor *)pieChart:(XYPieChart *)pieChart colorForSliceAtIndex:(NSUInteger)index;	//optional
- (NSString *)pieChart:(XYPieChart *)pieChart textForSliceAtIndex:(NSUInteger)index;	//optional

Implement  Delegate Methods (OPTIONAL):

- (void)pieChart:(XYPieChart *)pieChart willSelectSliceAtIndex:(NSUInteger)index;
- (void)pieChart:(XYPieChart *)pieChart didSelectSliceAtIndex:(NSUInteger)index;
- (void)pieChart:(XYPieChart *)pieChart willDeselectSliceAtIndex:(NSUInteger)index;
- (void)pieChart:(XYPieChart *)pieChart didDeselectSliceAtIndex:(NSUInteger)index;


XYPieChart is brought to you by XY Feng

You can’t perform that action at this time.