Showing
3 changed files
with
45 additions
and
51 deletions
| @@ -7,9 +7,6 @@ | @@ -7,9 +7,6 @@ | ||
| 7 | // | 7 | // |
| 8 | 8 | ||
| 9 | #import "PCChartsTableViewController.h" | 9 | #import "PCChartsTableViewController.h" |
| 10 | -#import "PNChart.h" | ||
| 11 | -#import "PNLineChartData.h" | ||
| 12 | -#import "PNLineChartDataItem.h" | ||
| 13 | 10 | ||
| 14 | @interface PCChartsTableViewController () | 11 | @interface PCChartsTableViewController () |
| 15 | 12 | ||
| @@ -32,7 +29,7 @@ | @@ -32,7 +29,7 @@ | ||
| 32 | 29 | ||
| 33 | // Uncomment the following line to preserve selection between presentations. | 30 | // Uncomment the following line to preserve selection between presentations. |
| 34 | // self.clearsSelectionOnViewWillAppear = NO; | 31 | // self.clearsSelectionOnViewWillAppear = NO; |
| 35 | - | 32 | + |
| 36 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. | 33 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. |
| 37 | // self.navigationItem.rightBarButtonItem = self.editButtonItem; | 34 | // self.navigationItem.rightBarButtonItem = self.editButtonItem; |
| 38 | } | 35 | } |
| @@ -48,18 +45,18 @@ | @@ -48,18 +45,18 @@ | ||
| 48 | { | 45 | { |
| 49 | // Get the new view controller using [segue destinationViewController]. | 46 | // Get the new view controller using [segue destinationViewController]. |
| 50 | // Pass the selected object to the new view controller. | 47 | // Pass the selected object to the new view controller. |
| 51 | - | 48 | + |
| 52 | UIViewController * viewController = [segue destinationViewController]; | 49 | UIViewController * viewController = [segue destinationViewController]; |
| 53 | - | 50 | + |
| 54 | if ([segue.identifier isEqualToString:@"lineChart"]) { | 51 | if ([segue.identifier isEqualToString:@"lineChart"]) { |
| 55 | - | 52 | + |
| 56 | //Add LineChart | 53 | //Add LineChart |
| 57 | UILabel * lineChartLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 90, SCREEN_WIDTH, 30)]; | 54 | UILabel * lineChartLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 90, SCREEN_WIDTH, 30)]; |
| 58 | lineChartLabel.text = @"Line Chart"; | 55 | lineChartLabel.text = @"Line Chart"; |
| 59 | lineChartLabel.textColor = PNFreshGreen; | 56 | lineChartLabel.textColor = PNFreshGreen; |
| 60 | lineChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; | 57 | lineChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; |
| 61 | lineChartLabel.textAlignment = NSTextAlignmentCenter; | 58 | lineChartLabel.textAlignment = NSTextAlignmentCenter; |
| 62 | - | 59 | + |
| 63 | PNLineChart * lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; | 60 | PNLineChart * lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; |
| 64 | lineChart.yLabelFormat = @"%1.1f"; | 61 | lineChart.yLabelFormat = @"%1.1f"; |
| 65 | lineChart.backgroundColor = [UIColor clearColor]; | 62 | lineChart.backgroundColor = [UIColor clearColor]; |
| @@ -90,24 +87,24 @@ | @@ -90,24 +87,24 @@ | ||
| 90 | 87 | ||
| 91 | lineChart.chartData = @[data01, data02]; | 88 | lineChart.chartData = @[data01, data02]; |
| 92 | [lineChart strokeChart]; | 89 | [lineChart strokeChart]; |
| 93 | - | 90 | + |
| 94 | lineChart.delegate = self; | 91 | lineChart.delegate = self; |
| 95 | - | 92 | + |
| 96 | [viewController.view addSubview:lineChartLabel]; | 93 | [viewController.view addSubview:lineChartLabel]; |
| 97 | [viewController.view addSubview:lineChart]; | 94 | [viewController.view addSubview:lineChart]; |
| 98 | - | 95 | + |
| 99 | viewController.title = @"Line Chart"; | 96 | viewController.title = @"Line Chart"; |
| 100 | - | 97 | + |
| 101 | }else if ([segue.identifier isEqualToString:@"barChart"]) | 98 | }else if ([segue.identifier isEqualToString:@"barChart"]) |
| 102 | { | 99 | { |
| 103 | //Add BarChart | 100 | //Add BarChart |
| 104 | - | 101 | + |
| 105 | UILabel * barChartLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 90, SCREEN_WIDTH, 30)]; | 102 | UILabel * barChartLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 90, SCREEN_WIDTH, 30)]; |
| 106 | barChartLabel.text = @"Bar Chart"; | 103 | barChartLabel.text = @"Bar Chart"; |
| 107 | barChartLabel.textColor = PNFreshGreen; | 104 | barChartLabel.textColor = PNFreshGreen; |
| 108 | barChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; | 105 | barChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; |
| 109 | barChartLabel.textAlignment = NSTextAlignmentCenter; | 106 | barChartLabel.textAlignment = NSTextAlignmentCenter; |
| 110 | - | 107 | + |
| 111 | self.barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; | 108 | self.barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; |
| 112 | self.barChart.backgroundColor = [UIColor clearColor]; | 109 | self.barChart.backgroundColor = [UIColor clearColor]; |
| 113 | self.barChart.yLabelFormatter = ^(CGFloat yValue){ | 110 | self.barChart.yLabelFormatter = ^(CGFloat yValue){ |
| @@ -123,71 +120,71 @@ | @@ -123,71 +120,71 @@ | ||
| 123 | self.barChart.barColorGradientStart = [UIColor blueColor]; | 120 | self.barChart.barColorGradientStart = [UIColor blueColor]; |
| 124 | 121 | ||
| 125 | [self.barChart strokeChart]; | 122 | [self.barChart strokeChart]; |
| 126 | - | 123 | + |
| 127 | - | 124 | + |
| 128 | 125 | ||
| 129 | self.barChart.delegate = self; | 126 | self.barChart.delegate = self; |
| 130 | - | 127 | + |
| 131 | [viewController.view addSubview:barChartLabel]; | 128 | [viewController.view addSubview:barChartLabel]; |
| 132 | [viewController.view addSubview:self.barChart]; | 129 | [viewController.view addSubview:self.barChart]; |
| 133 | - | 130 | + |
| 134 | viewController.title = @"Bar Chart"; | 131 | viewController.title = @"Bar Chart"; |
| 135 | }else if ([segue.identifier isEqualToString:@"circleChart"]) | 132 | }else if ([segue.identifier isEqualToString:@"circleChart"]) |
| 136 | { | 133 | { |
| 137 | - | 134 | + |
| 138 | //Add CircleChart | 135 | //Add CircleChart |
| 139 | - | 136 | + |
| 140 | - | 137 | + |
| 141 | UILabel * circleChartLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 90, SCREEN_WIDTH, 30)]; | 138 | UILabel * circleChartLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 90, SCREEN_WIDTH, 30)]; |
| 142 | circleChartLabel.text = @"Circle Chart"; | 139 | circleChartLabel.text = @"Circle Chart"; |
| 143 | circleChartLabel.textColor = PNFreshGreen; | 140 | circleChartLabel.textColor = PNFreshGreen; |
| 144 | circleChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; | 141 | circleChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; |
| 145 | circleChartLabel.textAlignment = NSTextAlignmentCenter; | 142 | circleChartLabel.textAlignment = NSTextAlignmentCenter; |
| 146 | - | 143 | + |
| 147 | PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:@100 andCurrent:@60 andClockwise:YES andShadow:YES]; | 144 | PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:@100 andCurrent:@60 andClockwise:YES andShadow:YES]; |
| 148 | circleChart.backgroundColor = [UIColor clearColor]; | 145 | circleChart.backgroundColor = [UIColor clearColor]; |
| 149 | [circleChart setStrokeColor:PNGreen]; | 146 | [circleChart setStrokeColor:PNGreen]; |
| 150 | [circleChart setStrokeColorGradientStart:[UIColor blueColor]]; | 147 | [circleChart setStrokeColorGradientStart:[UIColor blueColor]]; |
| 151 | [circleChart strokeChart]; | 148 | [circleChart strokeChart]; |
| 152 | - | 149 | + |
| 153 | [viewController.view addSubview:circleChartLabel]; | 150 | [viewController.view addSubview:circleChartLabel]; |
| 154 | 151 | ||
| 155 | [viewController.view addSubview:circleChart]; | 152 | [viewController.view addSubview:circleChart]; |
| 156 | viewController.title = @"Circle Chart"; | 153 | viewController.title = @"Circle Chart"; |
| 157 | - | 154 | + |
| 158 | }else if ([segue.identifier isEqualToString:@"pieChart"]) | 155 | }else if ([segue.identifier isEqualToString:@"pieChart"]) |
| 159 | { | 156 | { |
| 160 | - | 157 | + |
| 161 | //Add PieChart | 158 | //Add PieChart |
| 162 | UILabel * pieChartLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 90, SCREEN_WIDTH, 30)]; | 159 | UILabel * pieChartLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 90, SCREEN_WIDTH, 30)]; |
| 163 | pieChartLabel.text = @"Pie Chart"; | 160 | pieChartLabel.text = @"Pie Chart"; |
| 164 | pieChartLabel.textColor = PNFreshGreen; | 161 | pieChartLabel.textColor = PNFreshGreen; |
| 165 | pieChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; | 162 | pieChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; |
| 166 | pieChartLabel.textAlignment = NSTextAlignmentCenter; | 163 | pieChartLabel.textAlignment = NSTextAlignmentCenter; |
| 167 | - | 164 | + |
| 168 | - | 165 | + |
| 169 | - | 166 | + |
| 170 | NSArray *items = @[[PNPieChartDataItem dataItemWithValue:10 color:PNLightGreen], | 167 | NSArray *items = @[[PNPieChartDataItem dataItemWithValue:10 color:PNLightGreen], |
| 171 | [PNPieChartDataItem dataItemWithValue:20 color:PNFreshGreen description:@"WWDC"], | 168 | [PNPieChartDataItem dataItemWithValue:20 color:PNFreshGreen description:@"WWDC"], |
| 172 | [PNPieChartDataItem dataItemWithValue:40 color:PNDeepGreen description:@"GOOL I/O"], | 169 | [PNPieChartDataItem dataItemWithValue:40 color:PNDeepGreen description:@"GOOL I/O"], |
| 173 | ]; | 170 | ]; |
| 174 | - | 171 | + |
| 175 | - | 172 | + |
| 176 | - | 173 | + |
| 177 | PNPieChart *pieChart = [[PNPieChart alloc] initWithFrame:CGRectMake(40.0, 155.0, 240.0, 240.0) items:items]; | 174 | PNPieChart *pieChart = [[PNPieChart alloc] initWithFrame:CGRectMake(40.0, 155.0, 240.0, 240.0) items:items]; |
| 178 | pieChart.descriptionTextColor = [UIColor whiteColor]; | 175 | pieChart.descriptionTextColor = [UIColor whiteColor]; |
| 179 | pieChart.descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:14.0]; | 176 | pieChart.descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:14.0]; |
| 180 | pieChart.descriptionTextShadowColor = [UIColor clearColor]; | 177 | pieChart.descriptionTextShadowColor = [UIColor clearColor]; |
| 181 | [pieChart strokeChart]; | 178 | [pieChart strokeChart]; |
| 182 | - | 179 | + |
| 183 | - | 180 | + |
| 184 | [viewController.view addSubview:pieChartLabel]; | 181 | [viewController.view addSubview:pieChartLabel]; |
| 185 | [viewController.view addSubview:pieChart]; | 182 | [viewController.view addSubview:pieChart]; |
| 186 | - | 183 | + |
| 187 | viewController.title = @"Pie Chart"; | 184 | viewController.title = @"Pie Chart"; |
| 188 | - | 185 | + |
| 189 | } | 186 | } |
| 190 | - | 187 | + |
| 191 | } | 188 | } |
| 192 | 189 | ||
| 193 | -(void)userClickedOnLineKeyPoint:(CGPoint)point lineIndex:(NSInteger)lineIndex andPointIndex:(NSInteger)pointIndex{ | 190 | -(void)userClickedOnLineKeyPoint:(CGPoint)point lineIndex:(NSInteger)lineIndex andPointIndex:(NSInteger)pointIndex{ |
| @@ -200,29 +197,29 @@ | @@ -200,29 +197,29 @@ | ||
| 200 | 197 | ||
| 201 | - (void)userClickedOnBarCharIndex:(NSInteger)barIndex | 198 | - (void)userClickedOnBarCharIndex:(NSInteger)barIndex |
| 202 | { | 199 | { |
| 203 | - | 200 | + |
| 204 | NSLog(@"Click on bar %@", @(barIndex)); | 201 | NSLog(@"Click on bar %@", @(barIndex)); |
| 205 | - | 202 | + |
| 206 | PNBar * bar = [self.barChart.bars objectAtIndex:barIndex]; | 203 | PNBar * bar = [self.barChart.bars objectAtIndex:barIndex]; |
| 207 | - | 204 | + |
| 208 | CABasicAnimation *animation= [CABasicAnimation animationWithKeyPath:@"transform.scale"]; | 205 | CABasicAnimation *animation= [CABasicAnimation animationWithKeyPath:@"transform.scale"]; |
| 209 | - | 206 | + |
| 210 | animation.fromValue= @1.0; | 207 | animation.fromValue= @1.0; |
| 211 | - | 208 | + |
| 212 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 209 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 213 | - | 210 | + |
| 214 | animation.toValue= @1.1; | 211 | animation.toValue= @1.1; |
| 215 | - | 212 | + |
| 216 | animation.duration= 0.2; | 213 | animation.duration= 0.2; |
| 217 | - | 214 | + |
| 218 | animation.repeatCount = 0; | 215 | animation.repeatCount = 0; |
| 219 | - | 216 | + |
| 220 | animation.autoreverses = YES; | 217 | animation.autoreverses = YES; |
| 221 | - | 218 | + |
| 222 | animation.removedOnCompletion = YES; | 219 | animation.removedOnCompletion = YES; |
| 223 | - | 220 | + |
| 224 | animation.fillMode=kCAFillModeForwards; | 221 | animation.fillMode=kCAFillModeForwards; |
| 225 | - | 222 | + |
| 226 | [bar.layer addAnimation:animation forKey:@"Float"]; | 223 | [bar.layer addAnimation:animation forKey:@"Float"]; |
| 227 | } | 224 | } |
| 228 | 225 |
| @@ -6,8 +6,6 @@ | @@ -6,8 +6,6 @@ | ||
| 6 | // Copyright (c) 2013年 kevinzhow. All rights reserved. | 6 | // Copyright (c) 2013年 kevinzhow. All rights reserved. |
| 7 | // | 7 | // |
| 8 | 8 | ||
| 9 | -#import <UIKit/UIKit.h> | ||
| 10 | - | ||
| 11 | #import "PCAppDelegate.h" | 9 | #import "PCAppDelegate.h" |
| 12 | 10 | ||
| 13 | int main(int argc, char * argv[]) | 11 | int main(int argc, char * argv[]) |
-
Please register or login to post a comment