Skip to content

Commit

Permalink
Merge pull request #51 from rochefort/modern-syntax
Browse files Browse the repository at this point in the history
Convert to modern Objective-C syntax
  • Loading branch information
kevinzhow committed May 5, 2014
2 parents af4727a + 545eafb commit ed66906
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions PNChart/PNBarChart/PNBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ - (void)setGrade:(float)grade
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.0;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
pathAnimation.fromValue = @0.0f;
pathAnimation.toValue = @1.0f;
[_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"];

_chartLine.strokeEnd = 1.0;
Expand Down
8 changes: 4 additions & 4 deletions PNChart/PNBarChart/PNBarChart.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ - (void)strokeChart
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 0.5;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
pathAnimation.fromValue = @0.0f;
pathAnimation.toValue = @1.0f;
[_chartBottomLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"];

_chartBottomLine.strokeEnd = 1.0;
Expand Down Expand Up @@ -276,8 +276,8 @@ - (void)strokeChart
CABasicAnimation *pathLeftAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathLeftAnimation.duration = 0.5;
pathLeftAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathLeftAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathLeftAnimation.toValue = [NSNumber numberWithFloat:1.0f];
pathLeftAnimation.fromValue = @0.0f;
pathLeftAnimation.toValue = @1.0f;
[_chartLeftLine addAnimation:pathLeftAnimation forKey:@"strokeEndAnimation"];

_chartLeftLine.strokeEnd = 1.0;
Expand Down
6 changes: 3 additions & 3 deletions PNChart/PNCircleChart/PNCircleChart.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ - (id)initWithFrame:(CGRect)frame andTotal:(NSNumber *)total andCurrent:(NSNumbe
CGFloat startAngle = clockwise ? -90.0f : 270.0f;
CGFloat endAngle = clockwise ? -90.01f : 270.01f;

_lineWidth = [NSNumber numberWithFloat:8.0];
_lineWidth = @8.0f;
UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.center.x, self.center.y) radius:self.frame.size.height * 0.5 startAngle:DEGREES_TO_RADIANS(startAngle) endAngle:DEGREES_TO_RADIANS(endAngle) clockwise:clockwise];

_circle = [CAShapeLayer layer];
Expand Down Expand Up @@ -94,8 +94,8 @@ - (void)strokeChart
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.0;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:[_current floatValue] / [_total floatValue]];
pathAnimation.fromValue = @0.0f;
pathAnimation.toValue = @([_current floatValue] / [_total floatValue]);
[_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
_circle.strokeEnd = [_current floatValue] / [_total floatValue];

Expand Down
4 changes: 2 additions & 2 deletions PNChart/PNLineChart/PNLineChart.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ - (void)strokeChart
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.0;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
pathAnimation.fromValue = @0.0f;
pathAnimation.toValue = @1.0f;
[chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"];

chartLine.strokeEnd = 1.0;
Expand Down
6 changes: 3 additions & 3 deletions PNChartDemo/PCChartsTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
data01.color = PNFreshGreen;
data01.itemCount = lineChart.xLabels.count;
data01.getData = ^(NSUInteger index) {
CGFloat yValue = [[data01Array objectAtIndex:index] floatValue];
CGFloat yValue = [data01Array[index] floatValue];
return [PNLineChartDataItem dataItemWithY:yValue];
};

Expand All @@ -80,7 +80,7 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
data02.color = PNTwitterColor;
data02.itemCount = lineChart.xLabels.count;
data02.getData = ^(NSUInteger index) {
CGFloat yValue = [[data02Array objectAtIndex:index] floatValue];
CGFloat yValue = [data02Array[index] floatValue];
return [PNLineChartDataItem dataItemWithY:yValue];
};

Expand Down Expand Up @@ -135,7 +135,7 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
circleChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0];
circleChartLabel.textAlignment = NSTextAlignmentCenter;

PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:[NSNumber numberWithInt:100] andCurrent:[NSNumber numberWithInt:60] andClockwise:YES andShadow:YES];
PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:@100 andCurrent:@60 andClockwise:YES andShadow:YES];
circleChart.backgroundColor = [UIColor clearColor];
[circleChart setStrokeColor:PNGreen];
[circleChart strokeChart];
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ You will need LLVM 3.0 or later in order to build PNChart.
data01.color = PNFreshGreen;
data01.itemCount = lineChart.xLabels.count;
data01.getData = ^(NSUInteger index) {
CGFloat yValue = [[data01Array objectAtIndex:index] floatValue];
CGFloat yValue = [data01Array[index] floatValue];
return [PNLineChartDataItem dataItemWithY:yValue];
};
// Line Chart No.2
Expand All @@ -58,7 +58,7 @@ You will need LLVM 3.0 or later in order to build PNChart.
data02.color = PNTwitterColor;
data02.itemCount = lineChart.xLabels.count;
data02.getData = ^(NSUInteger index) {
CGFloat yValue = [[data02Array objectAtIndex:index] floatValue];
CGFloat yValue = [data02Array[index] floatValue];
return [PNLineChartDataItem dataItemWithY:yValue];
};

Expand Down

0 comments on commit ed66906

Please sign in to comment.