kevinzhow

Update readme for realtime update, #107

@@ -16,7 +16,7 @@ Pod::Spec.new do |s| @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
16 # 16 #
17 17
18 s.name = "PNChart" 18 s.name = "PNChart"
19 - s.version = "0.5.5" 19 + s.version = "0.6.0"
20 s.summary = "A simple and beautiful chart lib with animation used in Piner for iOS" 20 s.summary = "A simple and beautiful chart lib with animation used in Piner for iOS"
21 21
22 s.description = <<-DESC 22 s.description = <<-DESC
@@ -41,141 +41,6 @@ Pod::Spec.new do |s| @@ -41,141 +41,6 @@ Pod::Spec.new do |s|
41 41
42 You will need LLVM 3.0 or later in order to build PNChart. 42 You will need LLVM 3.0 or later in order to build PNChart.
43 43
44 -  
45 -  
46 -  
47 - ## Usage  
48 -  
49 - ### Cocoapods  
50 -  
51 - [CocoaPods](http://cocoapods.org) is the recommended way to add PNChart to your project.  
52 -  
53 - 1. Add a pod entry for PNChart to your Podfile `pod 'PNChart', '~> 0.5'`  
54 - 2. Install the pod(s) by running `pod install`.  
55 - 3. Include PNChart wherever you need it with `#import "PNChart.h"`.  
56 -  
57 -  
58 - ### Copy the PNChart folder to your project  
59 -  
60 -  
61 - [![](https://dl.dropboxusercontent.com/u/1599662/line.png)](https://dl.dropboxusercontent.com/u/1599662/line.png)  
62 -  
63 - ```objective-c  
64 - #import "PNChart.h"  
65 -  
66 - //For LineChart  
67 - PNLineChart * lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)];  
68 - [lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]];  
69 -  
70 - // Line Chart No.1  
71 - NSArray * data01Array = @[@60.1, @160.1, @126.4, @262.2, @186.2];  
72 - PNLineChartData *data01 = [PNLineChartData new];  
73 - data01.color = PNFreshGreen;  
74 - data01.itemCount = lineChart.xLabels.count;  
75 - data01.getData = ^(NSUInteger index) {  
76 - CGFloat yValue = [data01Array[index] floatValue];  
77 - return [PNLineChartDataItem dataItemWithY:yValue];  
78 - };  
79 - // Line Chart No.2  
80 - NSArray * data02Array = @[@20.1, @180.1, @26.4, @202.2, @126.2];  
81 - PNLineChartData *data02 = [PNLineChartData new];  
82 - data02.color = PNTwitterColor;  
83 - data02.itemCount = lineChart.xLabels.count;  
84 - data02.getData = ^(NSUInteger index) {  
85 - CGFloat yValue = [data02Array[index] floatValue];  
86 - return [PNLineChartDataItem dataItemWithY:yValue];  
87 - };  
88 -  
89 - lineChart.chartData = @[data01, data02];  
90 - [lineChart strokeChart];  
91 -  
92 - ```  
93 -  
94 - [![](https://dl.dropboxusercontent.com/u/1599662/bar.png)](https://dl.dropboxusercontent.com/u/1599662/bar.png)  
95 -  
96 - ```objective-c  
97 - #import "PNChart.h"  
98 -  
99 - //For BarChart  
100 - PNBarChart * barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)];  
101 - [barChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]];  
102 - [barChart setYValues:@[@1, @10, @2, @6, @3]];  
103 - [barChart strokeChart];  
104 -  
105 - ```  
106 -  
107 - [![](https://dl.dropboxusercontent.com/u/1599662/circle.png)](https://dl.dropboxusercontent.com/u/1599662/circle.png)  
108 -  
109 -  
110 - ```objective-c  
111 - #import "PNChart.h"  
112 -  
113 - //For CircleChart  
114 -  
115 - PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:[NSNumber numberWithInt:100] andCurrent:[NSNumber numberWithInt:60] andClockwise:NO];  
116 - circleChart.backgroundColor = [UIColor clearColor];  
117 - [circleChart setStrokeColor:PNGreen];  
118 - [circleChart strokeChart];  
119 -  
120 - ```  
121 -  
122 -  
123 - [![](https://dl.dropboxusercontent.com/u/1599662/pie.png)](https://dl.dropboxusercontent.com/u/1599662/pie.png)  
124 -  
125 - ```objective-c  
126 - # import "PNChart.h"  
127 - //For PieChart  
128 - NSArray *items = @[[PNPieChartDataItem dataItemWithValue:10 color:PNRed],  
129 - [PNPieChartDataItem dataItemWithValue:20 color:PNBlue description:@"WWDC"],  
130 - [PNPieChartDataItem dataItemWithValue:40 color:PNGreen description:@"GOOL I/O"],  
131 - ];  
132 -  
133 -  
134 -  
135 - PNPieChart *pieChart = [[PNPieChart alloc] initWithFrame:CGRectMake(40.0, 155.0, 240.0, 240.0) items:items];  
136 - pieChart.descriptionTextColor = [UIColor whiteColor];  
137 - pieChart.descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:14.0];  
138 - [pieChart strokeChart];  
139 - ```  
140 -  
141 - #### Callback  
142 -  
143 - Currently callback only works on Linechart  
144 -  
145 - ```objective-c  
146 - #import "PNChart.h"  
147 -  
148 - //For LineChart  
149 -  
150 - lineChart.delegate = self;  
151 -  
152 -  
153 - ```  
154 -  
155 - ```objective-c  
156 -  
157 - //For DelegateMethod  
158 -  
159 -  
160 - -(void)userClickedOnLineKeyPoint:(CGPoint)point lineIndex:(NSInteger)lineIndex pointIndex:(NSInteger)pointIndex{  
161 - NSLog(@"Click Key on line %f, %f line index is %d and point index is %d",point.x, point.y,(int)lineIndex, (int)pointIndex);  
162 - }  
163 -  
164 - -(void)userClickedOnLinePoint:(CGPoint)point lineIndex:(NSInteger)lineIndex{  
165 - NSLog(@"Click on line %f, %f, line index is %d",point.x, point.y, (int)lineIndex);  
166 - }  
167 -  
168 - ```  
169 -  
170 -  
171 - ## License  
172 -  
173 - This code is distributed under the terms and conditions of the [MIT license](LICENSE).  
174 -  
175 - ## SpecialThanks  
176 -  
177 - [@lexrus](http://twitter.com/lexrus) CocoaPods Spec  
178 -  
179 DESC 44 DESC
180 45
181 s.homepage = "https://github.com/kevinzhow/PNChart" 46 s.homepage = "https://github.com/kevinzhow/PNChart"
@@ -225,7 +90,7 @@ Pod::Spec.new do |s| @@ -225,7 +90,7 @@ Pod::Spec.new do |s|
225 # Supports git, hg, bzr, svn and HTTP. 90 # Supports git, hg, bzr, svn and HTTP.
226 # 91 #
227 92
228 - s.source = { :git => "https://github.com/kevinzhow/PNChart.git", :tag => "0.5.5" } 93 + s.source = { :git => "https://github.com/kevinzhow/PNChart.git", :tag => "0.6.0" }
229 94
230 95
231 # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 96 # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
@@ -28,7 +28,7 @@ You will need LLVM 3.0 or later in order to build PNChart. @@ -28,7 +28,7 @@ You will need LLVM 3.0 or later in order to build PNChart.
28 28
29 [CocoaPods](http://cocoapods.org) is the recommended way to add PNChart to your project. 29 [CocoaPods](http://cocoapods.org) is the recommended way to add PNChart to your project.
30 30
31 -1. Add a pod entry for PNChart to your Podfile `pod 'PNChart', '~> 0.5.5'` 31 +1. Add a pod entry for PNChart to your Podfile `pod 'PNChart', '~> 0.6.0'`
32 2. Install the pod(s) by running `pod install`. 32 2. Install the pod(s) by running `pod install`.
33 3. Include PNChart wherever you need it with `#import "PNChart.h"`. 33 3. Include PNChart wherever you need it with `#import "PNChart.h"`.
34 34
@@ -116,12 +116,54 @@ pieChart.descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:14.0] @@ -116,12 +116,54 @@ pieChart.descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:14.0]
116 [pieChart strokeChart]; 116 [pieChart strokeChart];
117 ``` 117 ```
118 118
119 -#### Callback 119 +#### Update Value
120 120
121 -Currently callback only works on Linechart 121 +Now it's easy to update value in real time
122 122
123 ```objective-c 123 ```objective-c
124 - #import "PNChart.h" 124 +if ([self.title isEqualToString:@"Line Chart"]) {
  125 +
  126 + // Line Chart #1
  127 + NSArray * data01Array = @[@(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300)];
  128 + PNLineChartData *data01 = [PNLineChartData new];
  129 + data01.color = PNFreshGreen;
  130 + data01.itemCount = data01Array.count;
  131 + data01.inflexionPointStyle = PNLineChartPointStyleTriangle;
  132 + data01.getData = ^(NSUInteger index) {
  133 + CGFloat yValue = [data01Array[index] floatValue];
  134 + return [PNLineChartDataItem dataItemWithY:yValue];
  135 + };
  136 +
  137 + // Line Chart #2
  138 + NSArray * data02Array = @[@(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300)];
  139 + PNLineChartData *data02 = [PNLineChartData new];
  140 + data02.color = PNTwitterColor;
  141 + data02.itemCount = data02Array.count;
  142 + data02.inflexionPointStyle = PNLineChartPointStyleSquare;
  143 + data02.getData = ^(NSUInteger index) {
  144 + CGFloat yValue = [data02Array[index] floatValue];
  145 + return [PNLineChartDataItem dataItemWithY:yValue];
  146 + };
  147 +
  148 + [self.lineChart setXLabels:@[@"DEC 1",@"DEC 2",@"DEC 3",@"DEC 4",@"DEC 5",@"DEC 6",@"DEC 7"]];
  149 + [self.lineChart updateChartData:@[data01, data02]];
  150 +
  151 +}
  152 +else if ([self.title isEqualToString:@"Bar Chart"])
  153 +{
  154 + [self.barChart setXLabels:@[@"Jan 1",@"Jan 2",@"Jan 3",@"Jan 4",@"Jan 5",@"Jan 6",@"Jan 7"]];
  155 + [self.barChart updateChartData:@[@(arc4random() % 30),@(arc4random() % 30),@(arc4random() % 30),@(arc4random() % 30),@(arc4random() % 30),@(arc4random() % 30),@(arc4random() % 30)]];
  156 +}
  157 +else if ([self.title isEqualToString:@"Circle Chart"])
  158 +{
  159 + [self.circleChart updateChartByCurrent:@(arc4random() % 100)];
  160 +}
  161 +```
  162 +
  163 +#### Callback
  164 +
  165 +```objective-c
  166 +#import "PNChart.h"
125 167
126 //For LineChart 168 //For LineChart
127 169