Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 2.64 KB

README.textile

File metadata and controls

62 lines (46 loc) · 2.64 KB

XYPieChart

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

Features

  • 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

Installation

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

Usage

(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 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

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;

Credits

XYPieChart is brought to you by XY Feng