#PNChart
A simple and beautiful chart lib with animation used in Piner and CoinsMan for iOS
PNChart works on iOS 6.0 and later version and is compatible with ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates:
- Foundation.framework
- UIKit.framework
- CoreGraphics.framework
- QuartzCore.framework
You will need LLVM 3.0 or later in order to build PNChart.
CocoaPods is the recommended way to add PNChart to your project.
- Add a pod entry for PNChart to your Podfile
pod 'PNChart', '~> 0.2.2'
- Install the pod(s) by running
pod install
. - Include PNChart wherever you need it with
#import "PNChart.h"
.
#import "PNChart.h"
//For LineChart
PNLineChart * lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)];
[lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]];
// Line Chart Nr.1
PNLineChartData *data01 = [PNLineChartData new];
data01.color = [UIColor redColor];
data01.itemCount = lineChart.xLabels.count;
data01.getData = ^(NSUInteger item) {
CGFloat y = item * 10;
return [PNLineChartDataItem dataItemWithY:y];
};
// Line Chart Nr.2
PNLineChartData *data02 = [PNLineChartData new];
data02.color = [UIColor blueColor];
data02.itemCount = lineChart.xLabels.count;
data02.getData = ^(NSUInteger item) {
CGFloat y = item == 0 ? (item * 5) + 10 : (item * 5);
return [PNLineChartDataItem dataItemWithY:y];
};
lineChart.chartData = @[data01, data02];
[lineChart strokeChart];
#import "PNChart.h"
//For BarChart
PNBarChart * barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)];
[barChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]];
[barChart setYValues:@[@1, @10, @2, @6, @3]];
[barChart strokeChart];
#import "PNChart.h"
//For CircleChart
PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:[NSNumber numberWithInt:100] andCurrent:[NSNumber numberWithInt:60]];
circleChart.backgroundColor = [UIColor clearColor];
[circleChart setStrokeColor:PNGreen];
[circleChart strokeChart];
Currently callback only works on Linechart
#import "PNChart.h"
//For LineChart
lineChart.delegate = self;
//For DelegateMethod
-(void)userClickedOnLineKeyPoint:(CGPoint)point lineIndex:(NSInteger)lineIndex andPointIndex:(NSInteger)pointIndex{
NSLog(@"Click Key on line %f, %f line index is %d and point index is %d",point.x, point.y,(int)lineIndex, (int)pointIndex);
}
-(void)userClickedOnLinePoint:(CGPoint)point lineIndex:(NSInteger)lineIndex{
NSLog(@"Click on line %f, %f, line index is %d",point.x, point.y, (int)lineIndex);
}
This code is distributed under the terms and conditions of the MIT license.
@lexrus CocoaPods Spec