Merge pull request #178 from antoninbiret/master
Fix #177
Showing
10 changed files
with
22 additions
and
15 deletions
| @@ -11,10 +11,10 @@ | @@ -11,10 +11,10 @@ | ||
| 11 | #import "PNChartDelegate.h" | 11 | #import "PNChartDelegate.h" |
| 12 | #import "PNBar.h" | 12 | #import "PNBar.h" |
| 13 | 13 | ||
| 14 | -#define xLabelMargin 15 | 14 | +#define kXLabelMargin 15 |
| 15 | -#define yLabelMargin 15 | 15 | +#define kYLabelMargin 15 |
| 16 | -#define yLabelHeight 11 | 16 | +#define kYLabelHeight 11 |
| 17 | -#define xLabelHeight 20 | 17 | +#define kXLabelHeight 20 |
| 18 | 18 | ||
| 19 | typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue); | 19 | typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue); |
| 20 | 20 |
| @@ -87,16 +87,16 @@ | @@ -87,16 +87,16 @@ | ||
| 87 | if (_showLabel) { | 87 | if (_showLabel) { |
| 88 | //Add y labels | 88 | //Add y labels |
| 89 | 89 | ||
| 90 | - float yLabelSectionHeight = (self.frame.size.height - _chartMargin * 2 - xLabelHeight) / _yLabelSum; | 90 | + float yLabelSectionHeight = (self.frame.size.height - _chartMargin * 2 - kXLabelHeight) / _yLabelSum; |
| 91 | 91 | ||
| 92 | for (int index = 0; index < _yLabelSum; index++) { | 92 | for (int index = 0; index < _yLabelSum; index++) { |
| 93 | 93 | ||
| 94 | NSString *labelText = _yLabelFormatter((float)_yValueMax * ( (_yLabelSum - index) / (float)_yLabelSum )); | 94 | NSString *labelText = _yLabelFormatter((float)_yValueMax * ( (_yLabelSum - index) / (float)_yLabelSum )); |
| 95 | 95 | ||
| 96 | PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0, | 96 | PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0, |
| 97 | - yLabelSectionHeight * index + _chartMargin - yLabelHeight/2.0, | 97 | + yLabelSectionHeight * index + _chartMargin - kYLabelHeight/2.0, |
| 98 | _yChartLabelWidth, | 98 | _yChartLabelWidth, |
| 99 | - yLabelHeight)]; | 99 | + kYLabelHeight)]; |
| 100 | label.font = _labelFont; | 100 | label.font = _labelFont; |
| 101 | label.textColor = _labelTextColor; | 101 | label.textColor = _labelTextColor; |
| 102 | [label setTextAlignment:NSTextAlignmentRight]; | 102 | [label setTextAlignment:NSTextAlignmentRight]; |
| @@ -144,7 +144,7 @@ | @@ -144,7 +144,7 @@ | ||
| 144 | 144 | ||
| 145 | if (labelAddCount == _xLabelSkip) { | 145 | if (labelAddCount == _xLabelSkip) { |
| 146 | NSString *labelText = [_xLabels[index] description]; | 146 | NSString *labelText = [_xLabels[index] description]; |
| 147 | - PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0, 0, _xLabelWidth, xLabelHeight)]; | 147 | + PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0, 0, _xLabelWidth, kXLabelHeight)]; |
| 148 | label.font = _labelFont; | 148 | label.font = _labelFont; |
| 149 | label.textColor = _labelTextColor; | 149 | label.textColor = _labelTextColor; |
| 150 | [label setTextAlignment:NSTextAlignmentCenter]; | 150 | [label setTextAlignment:NSTextAlignmentCenter]; |
| @@ -159,7 +159,7 @@ | @@ -159,7 +159,7 @@ | ||
| 159 | labelXPosition = (index * _xLabelWidth + _chartMargin + _xLabelWidth /2.0 ); | 159 | labelXPosition = (index * _xLabelWidth + _chartMargin + _xLabelWidth /2.0 ); |
| 160 | } | 160 | } |
| 161 | label.center = CGPointMake(labelXPosition, | 161 | label.center = CGPointMake(labelXPosition, |
| 162 | - self.frame.size.height - xLabelHeight - _chartMargin + label.frame.size.height /2.0 + _labelMarginTop); | 162 | + self.frame.size.height - kXLabelHeight - _chartMargin + label.frame.size.height /2.0 + _labelMarginTop); |
| 163 | labelAddCount = 0; | 163 | labelAddCount = 0; |
| 164 | 164 | ||
| 165 | [_xChartLabels addObject:label]; | 165 | [_xChartLabels addObject:label]; |
| @@ -179,7 +179,7 @@ | @@ -179,7 +179,7 @@ | ||
| 179 | { | 179 | { |
| 180 | 180 | ||
| 181 | //Add bars | 181 | //Add bars |
| 182 | - CGFloat chartCavanHeight = self.frame.size.height - _chartMargin * 2 - xLabelHeight; | 182 | + CGFloat chartCavanHeight = self.frame.size.height - _chartMargin * 2 - kXLabelHeight; |
| 183 | NSInteger index = 0; | 183 | NSInteger index = 0; |
| 184 | 184 | ||
| 185 | for (NSNumber *valueString in _yValues) { | 185 | for (NSNumber *valueString in _yValues) { |
| @@ -208,7 +208,7 @@ | @@ -208,7 +208,7 @@ | ||
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | bar = [[PNBar alloc] initWithFrame:CGRectMake(barXPosition, //Bar X position | 210 | bar = [[PNBar alloc] initWithFrame:CGRectMake(barXPosition, //Bar X position |
| 211 | - self.frame.size.height - chartCavanHeight - xLabelHeight - _chartMargin, //Bar Y position | 211 | + self.frame.size.height - chartCavanHeight - kXLabelHeight - _chartMargin, //Bar Y position |
| 212 | barWidth, // Bar witdh | 212 | barWidth, // Bar witdh |
| 213 | chartCavanHeight)]; //Bar height | 213 | chartCavanHeight)]; //Bar height |
| 214 | 214 | ||
| @@ -270,8 +270,8 @@ | @@ -270,8 +270,8 @@ | ||
| 270 | 270 | ||
| 271 | UIBezierPath *progressline = [UIBezierPath bezierPath]; | 271 | UIBezierPath *progressline = [UIBezierPath bezierPath]; |
| 272 | 272 | ||
| 273 | - [progressline moveToPoint:CGPointMake(_chartMargin, self.frame.size.height - xLabelHeight - _chartMargin)]; | 273 | + [progressline moveToPoint:CGPointMake(_chartMargin, self.frame.size.height - kXLabelHeight - _chartMargin)]; |
| 274 | - [progressline addLineToPoint:CGPointMake(self.frame.size.width - _chartMargin, self.frame.size.height - xLabelHeight - _chartMargin)]; | 274 | + [progressline addLineToPoint:CGPointMake(self.frame.size.width - _chartMargin, self.frame.size.height - kXLabelHeight - _chartMargin)]; |
| 275 | 275 | ||
| 276 | [progressline setLineWidth:1.0]; | 276 | [progressline setLineWidth:1.0]; |
| 277 | [progressline setLineCapStyle:kCGLineCapSquare]; | 277 | [progressline setLineCapStyle:kCGLineCapSquare]; |
| @@ -302,7 +302,7 @@ | @@ -302,7 +302,7 @@ | ||
| 302 | 302 | ||
| 303 | UIBezierPath *progressLeftline = [UIBezierPath bezierPath]; | 303 | UIBezierPath *progressLeftline = [UIBezierPath bezierPath]; |
| 304 | 304 | ||
| 305 | - [progressLeftline moveToPoint:CGPointMake(_chartMargin, self.frame.size.height - xLabelHeight - _chartMargin)]; | 305 | + [progressLeftline moveToPoint:CGPointMake(_chartMargin, self.frame.size.height - kXLabelHeight - _chartMargin)]; |
| 306 | [progressLeftline addLineToPoint:CGPointMake(_chartMargin, _chartMargin)]; | 306 | [progressLeftline addLineToPoint:CGPointMake(_chartMargin, _chartMargin)]; |
| 307 | 307 | ||
| 308 | [progressLeftline setLineWidth:1.0]; | 308 | [progressLeftline setLineWidth:1.0]; |
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | // | 4 | // |
| 5 | 5 | ||
| 6 | #import <Foundation/Foundation.h> | 6 | #import <Foundation/Foundation.h> |
| 7 | +#import <UIKit/UIKit.h> | ||
| 7 | 8 | ||
| 8 | typedef NS_ENUM(NSUInteger, PNLineChartPointStyle) { | 9 | typedef NS_ENUM(NSUInteger, PNLineChartPointStyle) { |
| 9 | PNLineChartPointStyleNone = 0, | 10 | PNLineChartPointStyleNone = 0, |
| @@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
| 7 | // | 7 | // |
| 8 | 8 | ||
| 9 | #import <Foundation/Foundation.h> | 9 | #import <Foundation/Foundation.h> |
| 10 | +#import <UIKit/UIKit.h> | ||
| 10 | 11 | ||
| 11 | typedef NS_ENUM(NSUInteger, PNScatterChartPointStyle) { | 12 | typedef NS_ENUM(NSUInteger, PNScatterChartPointStyle) { |
| 12 | PNScatterChartPointStyleCircle = 0, | 13 | PNScatterChartPointStyleCircle = 0, |
-
Please register or login to post a comment