Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/maximbilan/ios-pie-chart
- Owner: maximbilan
- License: mit
- Created: 2014-01-25T20:01:44.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-09-21T13:29:50.000Z (over 6 years ago)
- Last Synced: 2024-04-20T11:04:16.329Z (8 months ago)
- Topics: chart, ios, ios-pie-chart, objective-c, ui, ui-components, ui-design, uikit
- Language: Objective-C
- Homepage:
- Size: 127 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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;