Showing
3 changed files
with
30 additions
and
29 deletions
| @@ -27,26 +27,26 @@ typedef NS_ENUM(NSUInteger, PNRadarChartLabelStyle) { | @@ -27,26 +27,26 @@ typedef NS_ENUM(NSUInteger, PNRadarChartLabelStyle) { | ||
| 27 | -(void)strokeChart; | 27 | -(void)strokeChart; |
| 28 | 28 | ||
| 29 | /** Array of `RadarChartDataItem` objects, one for each corner. */ | 29 | /** Array of `RadarChartDataItem` objects, one for each corner. */ |
| 30 | -@property(nonatomic)NSArray *chartData; | 30 | +@property (nonatomic) NSArray *chartData; |
| 31 | /** The unit of this chart ,default is 1 */ | 31 | /** The unit of this chart ,default is 1 */ |
| 32 | -@property(nonatomic)CGFloat valueDivider; | 32 | +@property (nonatomic) CGFloat valueDivider; |
| 33 | /** The maximum for the range of values to display on the chart */ | 33 | /** The maximum for the range of values to display on the chart */ |
| 34 | -@property(nonatomic)CGFloat maxValue; | 34 | +@property (nonatomic) CGFloat maxValue; |
| 35 | /** Default is gray. */ | 35 | /** Default is gray. */ |
| 36 | -@property(nonatomic)UIColor *webColor; | 36 | +@property (nonatomic) UIColor *webColor; |
| 37 | /** Default is green , with an alpha of 0.7 */ | 37 | /** Default is green , with an alpha of 0.7 */ |
| 38 | -@property(nonatomic)UIColor *plotColor; | 38 | +@property (nonatomic) UIColor *plotColor; |
| 39 | /** Default is black */ | 39 | /** Default is black */ |
| 40 | -@property(nonatomic)UIColor *fontColor; | 40 | +@property (nonatomic) UIColor *fontColor; |
| 41 | /** Default is orange */ | 41 | /** Default is orange */ |
| 42 | -@property(nonatomic)UIColor *graduationColor; | 42 | +@property (nonatomic) UIColor *graduationColor; |
| 43 | /** Default is 15 */ | 43 | /** Default is 15 */ |
| 44 | -@property(nonatomic)CGFloat fontSize; | 44 | +@property (nonatomic) CGFloat fontSize; |
| 45 | /** Controls the labels display style that around chart */ | 45 | /** Controls the labels display style that around chart */ |
| 46 | -@property(nonatomic,assign)PNRadarChartLabelStyle labelStyle; | 46 | +@property (nonatomic, assign) PNRadarChartLabelStyle labelStyle; |
| 47 | /** Tap the label will display detail value ,default is YES. */ | 47 | /** Tap the label will display detail value ,default is YES. */ |
| 48 | -@property(nonatomic,assign)BOOL isLabelTouchable; | 48 | +@property (nonatomic, assign) BOOL isLabelTouchable; |
| 49 | /** is show graduation on the chart ,default is NO. */ | 49 | /** is show graduation on the chart ,default is NO. */ |
| 50 | -@property(nonatomic,assign)BOOL isShowGraduation; | 50 | +@property (nonatomic, assign) BOOL isShowGraduation; |
| 51 | 51 | ||
| 52 | @end | 52 | @end |
| @@ -10,19 +10,20 @@ | @@ -10,19 +10,20 @@ | ||
| 10 | 10 | ||
| 11 | @interface PNRadarChart() | 11 | @interface PNRadarChart() |
| 12 | 12 | ||
| 13 | -@property(nonatomic)CGFloat centerX; | 13 | +@property (nonatomic) CGFloat centerX; |
| 14 | -@property(nonatomic)CGFloat centerY; | 14 | +@property (nonatomic) CGFloat centerY; |
| 15 | -@property(nonatomic)NSMutableArray *pointsToWebArrayArray; | 15 | +@property (nonatomic) NSMutableArray *pointsToWebArrayArray; |
| 16 | -@property(nonatomic)NSMutableArray *pointsToPlotArray; | 16 | +@property (nonatomic) NSMutableArray *pointsToPlotArray; |
| 17 | -@property(nonatomic)UILabel *detailLabel; | 17 | +@property (nonatomic) UILabel *detailLabel; |
| 18 | -@property(nonatomic)CGFloat lengthUnit; | 18 | +@property (nonatomic) CGFloat lengthUnit; |
| 19 | -@property(nonatomic)CAShapeLayer *chartPlot; | 19 | +@property (nonatomic) CAShapeLayer *chartPlot; |
| 20 | 20 | ||
| 21 | @end | 21 | @end |
| 22 | 22 | ||
| 23 | + | ||
| 23 | @implementation PNRadarChart | 24 | @implementation PNRadarChart |
| 24 | 25 | ||
| 25 | --(id)initWithFrame:(CGRect)frame items:(NSArray *)items valueDivider:(CGFloat)unitValue{ | 26 | +- (id)initWithFrame:(CGRect)frame items:(NSArray *)items valueDivider:(CGFloat)unitValue { |
| 26 | self=[super initWithFrame:frame]; | 27 | self=[super initWithFrame:frame]; |
| 27 | if (self) { | 28 | if (self) { |
| 28 | self.backgroundColor = [UIColor clearColor]; | 29 | self.backgroundColor = [UIColor clearColor]; |
| @@ -80,7 +81,7 @@ | @@ -80,7 +81,7 @@ | ||
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | #pragma mark - main | 83 | #pragma mark - main |
| 83 | --(void)calculateChartPoints{ | 84 | +- (void)calculateChartPoints { |
| 84 | [_pointsToPlotArray removeAllObjects]; | 85 | [_pointsToPlotArray removeAllObjects]; |
| 85 | [_pointsToWebArrayArray removeAllObjects]; | 86 | [_pointsToWebArrayArray removeAllObjects]; |
| 86 | 87 | ||
| @@ -181,7 +182,7 @@ | @@ -181,7 +182,7 @@ | ||
| 181 | 182 | ||
| 182 | } | 183 | } |
| 183 | 184 | ||
| 184 | --(void)strokeChart{ | 185 | +- (void)strokeChart { |
| 185 | 186 | ||
| 186 | [self calculateChartPoints]; | 187 | [self calculateChartPoints]; |
| 187 | [self setNeedsDisplay]; | 188 | [self setNeedsDisplay]; |
| @@ -226,7 +227,7 @@ | @@ -226,7 +227,7 @@ | ||
| 226 | 227 | ||
| 227 | #pragma mark - Helper | 228 | #pragma mark - Helper |
| 228 | 229 | ||
| 229 | --(void)drawLabelWithMaxLength:(CGFloat)maxLength labelArray:(NSArray *)labelArray angleArray:(NSArray *)angleArray{ | 230 | +- (void)drawLabelWithMaxLength:(CGFloat)maxLength labelArray:(NSArray *)labelArray angleArray:(NSArray *)angleArray { |
| 230 | //set labels | 231 | //set labels |
| 231 | int labelTag = 121; | 232 | int labelTag = 121; |
| 232 | while (true) { | 233 | while (true) { |
| @@ -283,7 +284,7 @@ | @@ -283,7 +284,7 @@ | ||
| 283 | 284 | ||
| 284 | } | 285 | } |
| 285 | 286 | ||
| 286 | --(void)tapLabel:(UITapGestureRecognizer *)recognizer{ | 287 | +- (void)tapLabel:(UITapGestureRecognizer *)recognizer { |
| 287 | UILabel *label=(UILabel*)recognizer.view; | 288 | UILabel *label=(UILabel*)recognizer.view; |
| 288 | _detailLabel.frame = CGRectMake(label.frame.origin.x, label.frame.origin.y-30, 50, 25); | 289 | _detailLabel.frame = CGRectMake(label.frame.origin.x, label.frame.origin.y-30, 50, 25); |
| 289 | for (PNRadarChartDataItem *item in _chartData) { | 290 | for (PNRadarChartDataItem *item in _chartData) { |
| @@ -296,7 +297,7 @@ | @@ -296,7 +297,7 @@ | ||
| 296 | 297 | ||
| 297 | } | 298 | } |
| 298 | 299 | ||
| 299 | --(void)showGraduation{ | 300 | +- (void)showGraduation { |
| 300 | int labelTag = 112; | 301 | int labelTag = 112; |
| 301 | while (true) { | 302 | while (true) { |
| 302 | UIView *label = [self viewWithTag:labelTag]; | 303 | UIView *label = [self viewWithTag:labelTag]; |
| @@ -322,7 +323,7 @@ | @@ -322,7 +323,7 @@ | ||
| 322 | 323 | ||
| 323 | } | 324 | } |
| 324 | 325 | ||
| 325 | --(NSArray *)getWebPointWithLength:(CGFloat)length angleArray:(NSArray *)angleArray{ | 326 | +- (NSArray *)getWebPointWithLength:(CGFloat)length angleArray:(NSArray *)angleArray { |
| 326 | NSMutableArray *pointArray = [NSMutableArray array]; | 327 | NSMutableArray *pointArray = [NSMutableArray array]; |
| 327 | for (NSNumber *angleNumber in angleArray) { | 328 | for (NSNumber *angleNumber in angleArray) { |
| 328 | CGFloat angle = [angleNumber floatValue]; | 329 | CGFloat angle = [angleNumber floatValue]; |
| @@ -334,7 +335,7 @@ | @@ -334,7 +335,7 @@ | ||
| 334 | 335 | ||
| 335 | } | 336 | } |
| 336 | 337 | ||
| 337 | --(NSArray *)getLengthArrayWithCircleNum:(int)plotCircles{ | 338 | +- (NSArray *)getLengthArrayWithCircleNum:(int)plotCircles { |
| 338 | NSMutableArray *lengthArray = [NSMutableArray array]; | 339 | NSMutableArray *lengthArray = [NSMutableArray array]; |
| 339 | CGFloat length = 0; | 340 | CGFloat length = 0; |
| 340 | for (int i = 0; i < plotCircles; i++) { | 341 | for (int i = 0; i < plotCircles; i++) { |
| @@ -344,7 +345,7 @@ | @@ -344,7 +345,7 @@ | ||
| 344 | return lengthArray; | 345 | return lengthArray; |
| 345 | } | 346 | } |
| 346 | 347 | ||
| 347 | --(CGFloat)getMaxWidthLabelFromArray:(NSArray *)keyArray withFontSize:(CGFloat)size{ | 348 | +- (CGFloat)getMaxWidthLabelFromArray:(NSArray *)keyArray withFontSize:(CGFloat)size { |
| 348 | CGFloat maxWidth = 0; | 349 | CGFloat maxWidth = 0; |
| 349 | for (NSString *str in keyArray) { | 350 | for (NSString *str in keyArray) { |
| 350 | CGSize detailSize = [str sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:_fontSize]}]; | 351 | CGSize detailSize = [str sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:_fontSize]}]; |
| @@ -353,7 +354,7 @@ | @@ -353,7 +354,7 @@ | ||
| 353 | return maxWidth; | 354 | return maxWidth; |
| 354 | } | 355 | } |
| 355 | 356 | ||
| 356 | --(CGFloat)getMaxValueFromArray:(NSArray *)valueArray{ | 357 | +- (CGFloat)getMaxValueFromArray:(NSArray *)valueArray { |
| 357 | CGFloat max = _maxValue; | 358 | CGFloat max = _maxValue; |
| 358 | for (NSNumber *valueNum in valueArray) { | 359 | for (NSNumber *valueNum in valueArray) { |
| 359 | CGFloat valueFloat = [valueNum floatValue]; | 360 | CGFloat valueFloat = [valueNum floatValue]; |
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | return item; | 18 | return item; |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | -- (void)setValue:(CGFloat)value{ | 21 | +- (void)setValue:(CGFloat)value { |
| 22 | if (value<0) { | 22 | if (value<0) { |
| 23 | _value = 0; | 23 | _value = 0; |
| 24 | NSLog(@"Value value can not be negative"); | 24 | NSLog(@"Value value can not be negative"); |
-
Please register or login to post a comment