Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/xyfeng/XYPieChart

A simple and animated Pie Chart for your iOS app.
https://github.com/xyfeng/XYPieChart

Last synced: about 2 months ago
JSON representation

A simple and animated Pie Chart for your iOS app.

Lists

README

        

h1. XYPieChart

XYPieChart is an simple and easy-to-use pie chart for iOS app. It started from a "Potion":http://www.potiondesign.com Project which needs an animated pie graph without interaction. All animation was implemented in the drawRect: method. After played with "BTSPieChart":https://github.com/briancoyner/Core-Animation-Pie-Chart, 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":http://vimeo.com/38069395

!https://dl.dropboxusercontent.com/u/11819416/blog/XYPieChart_Screenshot.png!

h2. 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(Automatic Reference Counting) support
* interface builder support

h2. Installation

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

h2. 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 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;

h2. Credits

XYPieChart is brought to you by "XY Feng":http://xystudio.cc