Gabe Heafitz

Auto-indent and remove trailing whitespace.

... ... @@ -63,10 +63,10 @@
[_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
_chartLine.strokeEnd = 1.0;
// Check if user wants to add a gradient from the start color to the bar color
if (_barColorGradientStart) {
// Add gradient
CAShapeLayer *gradientMask = [CAShapeLayer layer];
gradientMask.fillColor = [[UIColor clearColor] CGColor];
... ... @@ -74,8 +74,8 @@
gradientMask.lineWidth = self.frame.size.width;
gradientMask.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
gradientMask.path = progressline.CGPath;
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.startPoint = CGPointMake(0.5,1.0);
gradientLayer.endPoint = CGPointMake(0.5,0.0);
... ... @@ -86,11 +86,11 @@
(id)endColor.CGColor
];
gradientLayer.colors = colors;
[gradientLayer setMask:gradientMask];
[_chartLine addSublayer:gradientLayer];
gradientMask.strokeEnd = 1.0;
[gradientMask addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
}
... ... @@ -112,9 +112,9 @@
[sublayer removeFromSuperlayer];
}
_barColorGradientStart = barColorGradientStart;
[self setGrade:_grade];
}
// Only override drawRect: if you perform custom drawing.
... ...
... ... @@ -50,13 +50,13 @@
- (void)setYValues:(NSArray *)yValues
{
_yValues = yValues;
if (_yMaxValue) {
_yValueMax = _yMaxValue;
} else {
[self getYValueMax:yValues];
}
_xLabelWidth = (self.frame.size.width - _chartMargin * 2) / [_yValues count];
}
... ... @@ -64,9 +64,9 @@
- (void)getYValueMax:(NSArray *)yLabels
{
int max = [[yLabels valueForKeyPath:@"@max.intValue"] intValue];
_yValueMax = (int)max;
if (_yValueMax == 0) {
_yValueMax = _yMinValue;
}
... ... @@ -97,7 +97,7 @@
int labelAddCount = 0;
for (int index = 0; index < _xLabels.count; index++) {
labelAddCount += 1;
if (labelAddCount == _xLabelSkip) {
NSString *labelText = [_xLabels[index] description];
PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectZero];
... ... @@ -107,24 +107,24 @@
label.text = labelText;
[label sizeToFit];
CGFloat labelXPosition = (index * _xLabelWidth + _chartMargin + _xLabelWidth /2.0 );
label.center = CGPointMake(labelXPosition,
self.frame.size.height - xLabelHeight - _chartMargin + label.frame.size.height /2.0 + _labelMarginTop);
labelAddCount = 0;
[_labels addObject:label];
[self addSubview:label];
}
}
//Add y labels
float yLabelSectionHeight = (self.frame.size.height - _chartMargin * 2 - xLabelHeight) / _yLabelSum;
for (int index = 0; index < _yLabelSum; index++) {
NSString *labelText = _yLabelFormatter((float)_yValueMax * ( (_yLabelSum - index) / (float)_yLabelSum ));
PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0,
yLabelSectionHeight * index + _chartMargin - yLabelHeight/2.0,
_yChartLabelWidth,
... ... @@ -139,11 +139,11 @@
}
}
[self viewCleanupForCollection:_bars];
//Add bars
CGFloat chartCavanHeight = self.frame.size.height - _chartMargin * 2 - xLabelHeight;
NSInteger index = 0;
... ... @@ -152,15 +152,15 @@
float value = [valueString floatValue];
float grade = (float)value / (float)_yValueMax;
if (isnan(grade)) {
grade = 0;
}
PNBar *bar;
CGFloat barWidth;
CGFloat barXPosition;
if (_barWidth) {
barWidth = _barWidth;
barXPosition = index * _xLabelWidth + _chartMargin + _xLabelWidth /2.0 - _barWidth /2.0;
... ... @@ -168,112 +168,112 @@
barXPosition = index * _xLabelWidth + _chartMargin + _xLabelWidth * 0.25;
if (_showLabel) {
barWidth = _xLabelWidth * 0.5;
}
else {
barWidth = _xLabelWidth * 0.6;
}
}
bar = [[PNBar alloc] initWithFrame:CGRectMake(barXPosition, //Bar X position
self.frame.size.height - chartCavanHeight - xLabelHeight - _chartMargin, //Bar Y position
barWidth, // Bar witdh
chartCavanHeight)]; //Bar height
//Change Bar Radius
bar.barRadius = _barRadius;
//Change Bar Background color
bar.backgroundColor = _barBackgroundColor;
//Bar StrokColor First
if (self.strokeColor) {
bar.barColor = self.strokeColor;
}else{
bar.barColor = [self barColorAtIndex:index];
}
//Height Of Bar
bar.grade = grade;
// Add gradient
bar.barColorGradientStart = _barColorGradientStart;
//For Click Index
bar.tag = index;
[_bars addObject:bar];
[self addSubview:bar];
index += 1;
}
//Add chart border lines
if (_showChartBorder) {
_chartBottomLine = [CAShapeLayer layer];
_chartBottomLine.lineCap = kCALineCapButt;
_chartBottomLine.fillColor = [[UIColor whiteColor] CGColor];
_chartBottomLine.lineWidth = 1.0;
_chartBottomLine.strokeEnd = 0.0;
UIBezierPath *progressline = [UIBezierPath bezierPath];
[progressline moveToPoint:CGPointMake(_chartMargin, self.frame.size.height - xLabelHeight - _chartMargin)];
[progressline addLineToPoint:CGPointMake(self.frame.size.width - _chartMargin, self.frame.size.height - xLabelHeight - _chartMargin)];
[progressline setLineWidth:1.0];
[progressline setLineCapStyle:kCGLineCapSquare];
_chartBottomLine.path = progressline.CGPath;
_chartBottomLine.strokeColor = PNLightGrey.CGColor;
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 0.5;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = @0.0f;
pathAnimation.toValue = @1.0f;
[_chartBottomLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
_chartBottomLine.strokeEnd = 1.0;
[self.layer addSublayer:_chartBottomLine];
//Add left Chart Line
_chartLeftLine = [CAShapeLayer layer];
_chartLeftLine.lineCap = kCALineCapButt;
_chartLeftLine.fillColor = [[UIColor whiteColor] CGColor];
_chartLeftLine.lineWidth = 1.0;
_chartLeftLine.strokeEnd = 0.0;
UIBezierPath *progressLeftline = [UIBezierPath bezierPath];
[progressLeftline moveToPoint:CGPointMake(_chartMargin, self.frame.size.height - xLabelHeight - _chartMargin)];
[progressLeftline addLineToPoint:CGPointMake(_chartMargin, _chartMargin)];
[progressLeftline setLineWidth:1.0];
[progressLeftline setLineCapStyle:kCGLineCapSquare];
_chartLeftLine.path = progressLeftline.CGPath;
_chartLeftLine.strokeColor = PNLightGrey.CGColor;
CABasicAnimation *pathLeftAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathLeftAnimation.duration = 0.5;
pathLeftAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathLeftAnimation.fromValue = @0.0f;
pathLeftAnimation.toValue = @1.0f;
[_chartLeftLine addAnimation:pathLeftAnimation forKey:@"strokeEndAnimation"];
_chartLeftLine.strokeEnd = 1.0;
[self.layer addSublayer:_chartLeftLine];
}
}
... ... @@ -316,7 +316,7 @@
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self];
UIView *subview = [self hitTest:touchPoint withEvent:nil];
if ([subview isKindOfClass:[PNBar class]] && [self.delegate respondsToSelector:@selector(userClickedOnBarAtIndex:)]) {
[self.delegate userClickedOnBarAtIndex:subview.tag];
}
... ...
... ... @@ -75,19 +75,19 @@
- (void)strokeChart
{
// Add counting label
NSString *format;
switch (self.chartType) {
case PNChartFormatTypePercent:
format = @"%d%%";
break;
case PNChartFormatTypeDollar:
format = @"$%d";
break;
case PNChartFormatTypeNone:
default:
format = @"%d";
break;
case PNChartFormatTypePercent:
format = @"%d%%";
break;
case PNChartFormatTypeDollar:
format = @"$%d";
break;
case PNChartFormatTypeNone:
default:
format = @"%d";
break;
}
self.countingLabel.format = format;
[self addSubview:self.countingLabel];
... ... @@ -110,11 +110,11 @@
_circle.strokeEnd = [_current floatValue] / [_total floatValue];
[_countingLabel countFrom:0 to:[_current floatValue] withDuration:1.0];
// Check if user wants to add a gradient from the start color to the bar color
if (_strokeColorGradientStart) {
// Add gradient
CAShapeLayer *gradientMask = [CAShapeLayer layer];
gradientMask.fillColor = [[UIColor clearColor] CGColor];
... ... @@ -124,7 +124,7 @@
CGRect gradientFrame = CGRectMake(0, 0, 2*self.bounds.size.width, 2*self.bounds.size.height);
gradientMask.frame = gradientFrame;
gradientMask.path = _circle.path;
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.startPoint = CGPointMake(0.5,1.0);
gradientLayer.endPoint = CGPointMake(0.5,0.0);
... ... @@ -135,13 +135,13 @@
(id)_strokeColorGradientStart.CGColor
];
gradientLayer.colors = colors;
[gradientLayer setMask:gradientMask];
[_circle addSublayer:gradientLayer];
gradientMask.strokeEnd = [_current floatValue] / [_total floatValue];
[gradientMask addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
}
}
... ... @@ -151,7 +151,7 @@
- (void)growChartByAmount:(NSNumber *)growAmount
{
NSNumber *updatedValue = [NSNumber numberWithFloat:[_current floatValue] + [growAmount floatValue]];
// Add animation
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = self.duration;
... ... @@ -160,7 +160,7 @@
pathAnimation.toValue = @([updatedValue floatValue] / [_total floatValue]);
_circle.strokeEnd = [updatedValue floatValue] / [_total floatValue];
[_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
[self.countingLabel countFrom:fmin([_current floatValue], [_total floatValue]) to:fmin([_current floatValue] + [growAmount floatValue], [_total floatValue]) withDuration:self.duration];
_current = updatedValue;
}
... ...
... ... @@ -20,6 +20,7 @@
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
... ...
... ... @@ -20,7 +20,6 @@
@property (nonatomic, retain) id<PNChartDelegate> delegate;
@property (nonatomic) NSArray *xLabels;
@property (nonatomic) NSArray *yLabels;
/**
... ... @@ -29,31 +28,18 @@
@property (nonatomic) NSArray *chartData;
@property (nonatomic) NSMutableArray *pathPoints;
@property (nonatomic) CGFloat xLabelWidth;
@property (nonatomic) UIFont *xLabelFont;
@property (nonatomic) UIColor *xLabelColor;
@property (nonatomic) CGFloat yValueMax;
@property (nonatomic) CGFloat yValueMin;
@property (nonatomic) NSInteger yLabelNum;
@property (nonatomic) CGFloat yLabelHeight;
@property (nonatomic) UIFont *yLabelFont;
@property (nonatomic) UIColor *yLabelColor;
@property (nonatomic) CGFloat chartCavanHeight;
@property (nonatomic) CGFloat chartCavanWidth;
@property (nonatomic) CGFloat chartMargin;
@property (nonatomic) BOOL showLabel;
/**
... ...
... ... @@ -6,7 +6,6 @@
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, PNLineChartPointStyle) {
PNLineChartPointStyleNone = 0,
PNLineChartPointStyleCircle = 1,
PNLineChartPointStyleSquare = 3
... ...
... ... @@ -21,7 +21,7 @@
+ (instancetype)dataItemWithValue:(CGFloat)value
color:(UIColor*)color
description:(NSString *)description{
description:(NSString *)description {
PNPieChartDataItem *item = [PNPieChartDataItem dataItemWithValue:value color:color];
item.textDescription = description;
return item;
... ...
... ... @@ -15,7 +15,7 @@
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
... ... @@ -24,7 +24,7 @@
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
... ...
... ... @@ -10,5 +10,4 @@
@interface PCChartViewController : UIViewController
@end
... ...