kevinzhow /PNChart

A simple and beautiful chart lib used in Piner and CoinsMan for iOS

★ 9,627⑂ 1,732👁 320⑃ 146● 317▤ 2
Objective-CMITCreated 2013-11-06
Download: 0.5PNChart-0.5 ↓0.52014-05-05
+0
Daily
9,627
stars
1,732
forks
320
watchers
146
prs
317
issues
2
releases

README

PNChart



You can also find swift version at here https://github.com/kevinzhow/PNChart-Swift

A simple and beautiful chart lib with animation used in Piner and CoinsMan for iOS



 Requirements

PNChart works on iOS 7.0+ and is compatible with ARC projects.
If you need support for iOS 6, use PNChart <= 0.8.1. Note that 0.8.2 supports iOS 8.0+ only, 0.8.3 and newer supports iOS 7.0+.

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.


 Usage

 Cocoapods

CocoaPods is the recommended way to add PNChart to your project.

1. Add a pod entry for PNChart to your Podfile pod 'PNChart'
2. Install the pod(s) by running pod install.
3. Include PNChart wherever you need it with import "PNChart.h".


 Copy the PNChart folder to your project

objective-c
import "PNChart.h"

//For Line Chart
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 No.1
NSArray  data01Array = @[@60.1, @160.1, @126.4, @262.2, @186.2];
PNLineChartData data01 = [PNLineChartData new];
data01.color = PNFreshGreen;
data01.itemCount = lineChart.xLabels.count;
data01.getData = ^(NSUInteger index) {
    CGFloat yValue = [data01Array[index] floatValue];
    return [PNLineChartDataItem dataItemWithY:yValue];
};
// Line Chart No.2
NSArray  data02Array = @[@20.1, @180.1, @26.4, @202.2, @126.2];
PNLineChartData data02 = [PNLineChartData new];
data02.color = PNTwitterColor;
data02.itemCount = lineChart.xLabels.count;
data02.getData = ^(NSUInteger index) {
    CGFloat yValue = [data02Array[index] floatValue];
    return [PNLineChartDataItem dataItemWithY:yValue];
};

lineChart.chartData = @[data01, data02];
[lineChart strokeChart];



You can choose to show smooth lines.

objective-c
lineChart.showSmoothLines = YES;





You can set different colors for the same PNLineChartData item. for instance you can use "color" red for values less than 50 and use purple for values greater than 150.





objective-c
lineChartData.rangeColors = @[
        [[PNLineChartColorRange alloc] initWithRange:NSMakeRange(10, 30) color:[UIColor redColor]],
        [[PNLineChartColorRange alloc] initWithRange:NSMakeRange(100, 200) color:[UIColor purpleColor]]
];


objective-c
import "PNChart.h"

//For BarC hart
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];



objective-c
import "PNChart.h"

//For Circle Chart

PNCircleChart  circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) total:[NSNumber numberWithInt:100] current:[NSNumber numberWithInt:60] clockwise

Top issues

Latest release

0.5 0.5 2014-05-05
Now we have a simple & beautiful Pie Chart thx to @ZhangHang

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON