Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/maximbilan/ios-pie-chart

iOS Pie Chart
https://github.com/maximbilan/ios-pie-chart

chart ios ios-pie-chart objective-c ui ui-components ui-design uikit

Last synced: about 1 month ago
JSON representation

iOS Pie Chart

Awesome Lists containing this project

README

        

iOS Pie Chart
=============

A pie chart control.

![alt tag](https://raw.github.com/maximbilan/ios_pie_chart/master/img/img1.png)

## Installation

Add to your project the next source files:


Chart.h
Chart.m
ChartData.h
ChartData.m
ChartView.h
ChartView.m
LegendCellView.h
LegendCellView.m
LegendView.h
LegendView.m
NSString+Chart.h
NSString+Chart.m
UIColor+Chart.h
UIColor+Chart.m

## How to use

You can add view in the Interface Builder and set a class to Chart or create in the code:


Chart *chart = [[Chart alloc] initWithFrame:CGRectMake(0, 256, 256, 256)];
[self.view addSubview:chart];

For adding chart data, you can use the following code:


NSMutableArray *array = [[NSMutableArray alloc] init];

float total;
for (NSInteger groupIndex = 0; groupIndex < 5; ++groupIndex) {
[array removeAllObjects];
total = 0.0;
for (NSInteger itemIndex = 0; itemIndex < 10; ++itemIndex) {
ChartItem *item = [[ChartItem alloc] init];
item.name = [NSString stringWithFormat:@"Item %d", itemIndex];
item.value = RAND_FROM_TO(1, 500);
total += item.value;
[array addObject:item];
}
[self.chart setData:array withKey:[NSString stringWithFormat:@"Group %d", groupIndex+1] withTotal:total];
}

For scrolling datasets just tap on the chart.


If you have one set of data, and you won't scroll them, use the following property:

@property BOOL isScrollEnabled;