Kevin

Merge pull request #234 from Leii/Leii

Leii
@@ -18,3 +18,5 @@ @@ -18,3 +18,5 @@
18 #import "PNChartDelegate.h" 18 #import "PNChartDelegate.h"
19 #import "PNPieChart.h" 19 #import "PNPieChart.h"
20 #import "PNScatterChart.h" 20 #import "PNScatterChart.h"
  21 +#import "PNRadarChart.h"
  22 +#import "PNRadarChartDataItem.h"
  1 +//
  2 +// PNRadarChart.h
  3 +// PNChartDemo
  4 +//
  5 +// Created by Lei on 15/7/1.
  6 +// Copyright (c) 2015年 kevinzhow. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "PNGenericChart.h"
  11 +#import "PNRadarChartDataItem.h"
  12 +
  13 +#define MAXCIRCLE 20
  14 +
  15 +typedef NS_ENUM(NSUInteger, PNRadarChartLabelStyle) {
  16 + PNRadarChartLabelStyleCircle = 0,
  17 + PNRadarChartLabelStyleHorizontal,
  18 + PNRadarChartLabelStyleHidden,
  19 +};
  20 +
  21 +@interface PNRadarChart : PNGenericChart
  22 +
  23 +-(id)initWithFrame:(CGRect)frame items:(NSArray *)items valueDivider:(CGFloat)unitValue;
  24 +/**
  25 + *Draws the chart in an animated fashion.
  26 + */
  27 +-(void)strokeChart;
  28 +
  29 +/** Array of `RadarChartDataItem` objects, one for each corner. */
  30 +@property (nonatomic) NSArray *chartData;
  31 +/** The unit of this chart ,default is 1 */
  32 +@property (nonatomic) CGFloat valueDivider;
  33 +/** The maximum for the range of values to display on the chart */
  34 +@property (nonatomic) CGFloat maxValue;
  35 +/** Default is gray. */
  36 +@property (nonatomic) UIColor *webColor;
  37 +/** Default is green , with an alpha of 0.7 */
  38 +@property (nonatomic) UIColor *plotColor;
  39 +/** Default is black */
  40 +@property (nonatomic) UIColor *fontColor;
  41 +/** Default is orange */
  42 +@property (nonatomic) UIColor *graduationColor;
  43 +/** Default is 15 */
  44 +@property (nonatomic) CGFloat fontSize;
  45 +/** Controls the labels display style that around chart */
  46 +@property (nonatomic, assign) PNRadarChartLabelStyle labelStyle;
  47 +/** Tap the label will display detail value ,default is YES. */
  48 +@property (nonatomic, assign) BOOL isLabelTouchable;
  49 +/** is show graduation on the chart ,default is NO. */
  50 +@property (nonatomic, assign) BOOL isShowGraduation;
  51 +
  52 +@end
  1 +//
  2 +// PNRadarChart.m
  3 +// PNChartDemo
  4 +//
  5 +// Created by Lei on 15/7/1.
  6 +// Copyright (c) 2015年 kevinzhow. All rights reserved.
  7 +//
  8 +
  9 +#import "PNRadarChart.h"
  10 +
  11 +@interface PNRadarChart()
  12 +
  13 +@property (nonatomic) CGFloat centerX;
  14 +@property (nonatomic) CGFloat centerY;
  15 +@property (nonatomic) NSMutableArray *pointsToWebArrayArray;
  16 +@property (nonatomic) NSMutableArray *pointsToPlotArray;
  17 +@property (nonatomic) UILabel *detailLabel;
  18 +@property (nonatomic) CGFloat lengthUnit;
  19 +@property (nonatomic) CAShapeLayer *chartPlot;
  20 +
  21 +@end
  22 +
  23 +
  24 +@implementation PNRadarChart
  25 +
  26 +- (id)initWithFrame:(CGRect)frame items:(NSArray *)items valueDivider:(CGFloat)unitValue {
  27 + self=[super initWithFrame:frame];
  28 + if (self) {
  29 + self.backgroundColor = [UIColor clearColor];
  30 + self.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
  31 +
  32 + //Public iVar
  33 + if ([items count]< 3)//At least three corners of A polygon ,If the count of items is less than 3 will add 3 default values
  34 + {
  35 + NSLog( @"At least three items!");
  36 + NSArray *defaultArray = @[[PNRadarChartDataItem dataItemWithValue:0 description:@"Default"],
  37 + [PNRadarChartDataItem dataItemWithValue:0 description:@"Default"],
  38 + [PNRadarChartDataItem dataItemWithValue:0 description:@"Default"],
  39 + ];
  40 + defaultArray = [defaultArray arrayByAddingObjectsFromArray:items];
  41 + _chartData = [NSArray arrayWithArray:defaultArray];
  42 + }else{
  43 + _chartData = [NSArray arrayWithArray:items];
  44 + }
  45 + _valueDivider = unitValue;
  46 + _maxValue = 1;
  47 + _webColor = [UIColor grayColor];
  48 + _plotColor = [UIColor colorWithRed:.4 green:.8 blue:.4 alpha:.7];
  49 + _fontColor = [UIColor blackColor];
  50 + _graduationColor = [UIColor orangeColor];
  51 + _fontSize = 15;
  52 + _labelStyle = PNRadarChartLabelStyleHorizontal;
  53 + _isLabelTouchable = YES;
  54 + _isShowGraduation = NO;
  55 +
  56 + //Private iVar
  57 + _centerX = frame.size.width/2;
  58 + _centerY = frame.size.height/2;
  59 + _pointsToWebArrayArray = [NSMutableArray array];
  60 + _pointsToPlotArray = [NSMutableArray array];
  61 + _lengthUnit = 0;
  62 + _chartPlot = [CAShapeLayer layer];
  63 + _chartPlot.lineCap = kCALineCapButt;
  64 + _chartPlot.fillColor = _plotColor.CGColor;
  65 + _chartPlot.lineWidth = 1.0;
  66 + [self.layer addSublayer:_chartPlot];
  67 +
  68 + [super setupDefaultValues];
  69 + //init detailLabel
  70 + _detailLabel = [[UILabel alloc] init];
  71 + _detailLabel.backgroundColor = [UIColor colorWithRed:.9 green:.9 blue:.1 alpha:.9];
  72 + _detailLabel.textAlignment = NSTextAlignmentCenter;
  73 + _detailLabel.textColor = [UIColor colorWithWhite:1 alpha:1];
  74 + _detailLabel.font = [UIFont systemFontOfSize:15];
  75 + [_detailLabel setHidden:YES];
  76 + [self addSubview:_detailLabel];
  77 +
  78 + [self strokeChart];
  79 + }
  80 + return self;
  81 +}
  82 +
  83 +#pragma mark - main
  84 +- (void)calculateChartPoints {
  85 + [_pointsToPlotArray removeAllObjects];
  86 + [_pointsToWebArrayArray removeAllObjects];
  87 +
  88 + //init Descriptions , Values and Angles.
  89 + NSMutableArray *descriptions = [NSMutableArray array];
  90 + NSMutableArray *values = [NSMutableArray array];
  91 + NSMutableArray *angles = [NSMutableArray array];
  92 + for (int i=0;i<_chartData.count;i++) {
  93 + PNRadarChartDataItem *item = (PNRadarChartDataItem *)[_chartData objectAtIndex:i];
  94 + [descriptions addObject:item.textDescription];
  95 + [values addObject:[NSNumber numberWithFloat:item.value]];
  96 + CGFloat angleValue = (float)i/(float)[_chartData count]*2*M_PI;
  97 + [angles addObject:[NSNumber numberWithFloat:angleValue]];
  98 + }
  99 +
  100 + //calculate all the lengths
  101 + _maxValue = [self getMaxValueFromArray:values];
  102 + CGFloat margin = 0;
  103 + if (_labelStyle==PNRadarChartLabelStyleCircle) {
  104 + margin = MIN(_centerX , _centerY)*3/10;
  105 + }else if (_labelStyle==PNRadarChartLabelStyleHorizontal) {
  106 + margin = [self getMaxWidthLabelFromArray:descriptions withFontSize:_fontSize];
  107 + }
  108 + CGFloat maxLength = ceil(MIN(_centerX, _centerY) - margin);
  109 + int plotCircles = (_maxValue/_valueDivider);
  110 + if (plotCircles > MAXCIRCLE) {
  111 + NSLog(@"Circle number is higher than max");
  112 + plotCircles = MAXCIRCLE;
  113 + _valueDivider = _maxValue/plotCircles;
  114 + }
  115 + _lengthUnit = maxLength/plotCircles;
  116 + NSArray *lengthArray = [self getLengthArrayWithCircleNum:(int)plotCircles];
  117 +
  118 + //get all the points and plot
  119 + for (NSNumber *lengthNumber in lengthArray) {
  120 + CGFloat length = [lengthNumber floatValue];
  121 + [_pointsToWebArrayArray addObject:[self getWebPointWithLength:length angleArray:angles]];
  122 + }
  123 + int section = 0;
  124 + for (id value in values) {
  125 + CGFloat valueFloat = [value floatValue];
  126 + if (valueFloat>_maxValue) {
  127 + NSString *reason = [NSString stringWithFormat:@"Value number is higher than max -value: %f - maxValue: %f",valueFloat,_maxValue];
  128 + @throw [NSException exceptionWithName:NSInvalidArgumentException reason:reason userInfo:nil];
  129 + return;
  130 + }
  131 +
  132 + CGFloat length = valueFloat/_maxValue*maxLength;
  133 + CGFloat angle = [[angles objectAtIndex:section] floatValue];
  134 + CGFloat x = _centerX +length*cos(angle);
  135 + CGFloat y = _centerY +length*sin(angle);
  136 + NSValue* point = [NSValue valueWithCGPoint:CGPointMake(x, y)];
  137 + [_pointsToPlotArray addObject:point];
  138 + section++;
  139 + }
  140 + //set the labels
  141 + [self drawLabelWithMaxLength:maxLength labelArray:descriptions angleArray:angles];
  142 +
  143 + }
  144 +#pragma mark - Draw
  145 +
  146 +- (void)drawRect:(CGRect)rect {
  147 + // Drawing backgound
  148 + CGContextRef context = UIGraphicsGetCurrentContext();
  149 + CGContextClearRect(context, rect);
  150 + int section = 0;
  151 + //circles
  152 + for(NSArray *pointArray in _pointsToWebArrayArray){
  153 + //plot backgound
  154 + CGContextRef graphContext = UIGraphicsGetCurrentContext();
  155 + CGContextBeginPath(graphContext);
  156 + CGPoint beginPoint = [[pointArray objectAtIndex:0] CGPointValue];
  157 + CGContextMoveToPoint(graphContext, beginPoint.x, beginPoint.y);
  158 + for(NSValue* pointValue in pointArray){
  159 + CGPoint point = [pointValue CGPointValue];
  160 + CGContextAddLineToPoint(graphContext, point.x, point.y);
  161 + }
  162 + CGContextAddLineToPoint(graphContext, beginPoint.x, beginPoint.y);
  163 + CGContextSetStrokeColorWithColor(graphContext, _webColor.CGColor);
  164 + CGContextStrokePath(graphContext);
  165 +
  166 + }
  167 + //cuts
  168 + NSArray *largestPointArray = [_pointsToWebArrayArray lastObject];
  169 + for (NSValue *pointValue in largestPointArray){
  170 + section++;
  171 + if (section==1&&_isShowGraduation)continue;
  172 +
  173 + CGContextRef graphContext = UIGraphicsGetCurrentContext();
  174 + CGContextBeginPath(graphContext);
  175 + CGContextMoveToPoint(graphContext, _centerX, _centerY);
  176 + CGPoint point = [pointValue CGPointValue];
  177 + CGContextAddLineToPoint(graphContext, point.x, point.y);
  178 + CGContextSetStrokeColorWithColor(graphContext, _webColor.CGColor);
  179 + CGContextStrokePath(graphContext);
  180 + }
  181 +
  182 +
  183 +}
  184 +
  185 +- (void)strokeChart {
  186 +
  187 + [self calculateChartPoints];
  188 + [self setNeedsDisplay];
  189 + [_detailLabel setHidden:YES];
  190 +
  191 + //Draw plot
  192 + [_chartPlot removeAllAnimations];
  193 + UIBezierPath *plotline = [UIBezierPath bezierPath];
  194 + CGPoint beginPoint = [[_pointsToPlotArray objectAtIndex:0] CGPointValue];
  195 + [plotline moveToPoint:CGPointMake(beginPoint.x, beginPoint.y)];
  196 + for(NSValue *pointValue in _pointsToPlotArray){
  197 + CGPoint point = [pointValue CGPointValue];
  198 + [plotline addLineToPoint:CGPointMake(point.x ,point.y)];
  199 +
  200 + }
  201 + [plotline setLineWidth:1];
  202 + [plotline setLineCapStyle:kCGLineCapButt];
  203 +
  204 + _chartPlot.path = plotline.CGPath;
  205 +
  206 + CABasicAnimation *animateScale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
  207 + animateScale.fromValue = [NSNumber numberWithFloat:0.f];
  208 + animateScale.toValue = [NSNumber numberWithFloat:1.0f];
  209 +
  210 + CABasicAnimation *animateMove = [CABasicAnimation animationWithKeyPath:@"position"];
  211 + animateMove.fromValue = [NSValue valueWithCGPoint:CGPointMake(_centerX, _centerY)];
  212 + animateMove.toValue = [NSValue valueWithCGPoint:CGPointMake(0, 0)];
  213 +
  214 + CABasicAnimation *animateAlpha = [CABasicAnimation animationWithKeyPath:@"opacity"];
  215 + animateAlpha.fromValue = [NSNumber numberWithFloat:0.f];
  216 +
  217 + CAAnimationGroup *aniGroup = [CAAnimationGroup animation];
  218 + aniGroup.duration = 1.f;
  219 + aniGroup.repeatCount = 1;
  220 + aniGroup.animations = [NSArray arrayWithObjects:animateScale,animateMove,animateAlpha, nil];
  221 + aniGroup.removedOnCompletion = YES;
  222 +
  223 + [_chartPlot addAnimation:aniGroup forKey:nil];
  224 +
  225 + [self showGraduation];
  226 +}
  227 +
  228 +#pragma mark - Helper
  229 +
  230 +- (void)drawLabelWithMaxLength:(CGFloat)maxLength labelArray:(NSArray *)labelArray angleArray:(NSArray *)angleArray {
  231 + //set labels
  232 + int labelTag = 121;
  233 + while (true) {
  234 + UIView *label = [self viewWithTag:labelTag];
  235 + if(!label)break;
  236 + [label removeFromSuperview];
  237 + }
  238 + int section = 0;
  239 + CGFloat labelLength = maxLength + maxLength/10;
  240 +
  241 + for (NSString *labelString in labelArray) {
  242 + CGFloat angle = [[angleArray objectAtIndex:section] floatValue];
  243 + CGFloat x = _centerX + labelLength *cos(angle);
  244 + CGFloat y = _centerY + labelLength *sin(angle);
  245 +
  246 + UILabel *label = [[UILabel alloc] init] ;
  247 + label.backgroundColor = [UIColor clearColor];
  248 + label.font = [UIFont systemFontOfSize:_fontSize];
  249 + label.text = labelString;
  250 + label.tag = labelTag;
  251 + CGSize detailSize = [labelString sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:_fontSize]}];
  252 +
  253 + switch (_labelStyle) {
  254 + case PNRadarChartLabelStyleCircle:
  255 + label.frame = CGRectMake(x-5*_fontSize/2, y-_fontSize/2, 5*_fontSize, _fontSize);
  256 + label.transform = CGAffineTransformMakeRotation(((float)section/[labelArray count])*(2*M_PI)+M_PI_2);
  257 + label.textAlignment = NSTextAlignmentCenter;
  258 +
  259 + break;
  260 + case PNRadarChartLabelStyleHorizontal:
  261 + if (x<_centerX) {
  262 + label.frame = CGRectMake(x-detailSize.width, y-detailSize.height/2, detailSize.width, detailSize.height);
  263 + label.textAlignment = NSTextAlignmentRight;
  264 + }else{
  265 + label.frame = CGRectMake(x, y-detailSize.height/2, detailSize.width , detailSize.height);
  266 + label.textAlignment = NSTextAlignmentLeft;
  267 + }
  268 + break;
  269 + case PNRadarChartLabelStyleHidden:
  270 + [label setHidden:YES];
  271 + break;
  272 + default:
  273 + break;
  274 + }
  275 + [label sizeToFit];
  276 +
  277 + label.userInteractionEnabled = YES;
  278 + UITapGestureRecognizer *tapLabelGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapLabel:)];
  279 + [label addGestureRecognizer:tapLabelGesture];
  280 + [self addSubview:label];
  281 +
  282 + section ++;
  283 + }
  284 +
  285 +}
  286 +
  287 +- (void)tapLabel:(UITapGestureRecognizer *)recognizer {
  288 + UILabel *label=(UILabel*)recognizer.view;
  289 + _detailLabel.frame = CGRectMake(label.frame.origin.x, label.frame.origin.y-30, 50, 25);
  290 + for (PNRadarChartDataItem *item in _chartData) {
  291 + if ([label.text isEqualToString:item.textDescription]) {
  292 + _detailLabel.text = [NSString stringWithFormat:@"%.2f", item.value];
  293 + break;
  294 + }
  295 + }
  296 + [_detailLabel setHidden:NO];
  297 +
  298 +}
  299 +
  300 +- (void)showGraduation {
  301 + int labelTag = 112;
  302 + while (true) {
  303 + UIView *label = [self viewWithTag:labelTag];
  304 + if(!label)break;
  305 + [label removeFromSuperview];
  306 + }
  307 + int section = 0;
  308 + for (NSArray *pointsArray in _pointsToWebArrayArray) {
  309 + section++;
  310 + CGPoint labelPoint = [[pointsArray objectAtIndex:0] CGPointValue];
  311 + UILabel *graduationLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelPoint.x-_lengthUnit, labelPoint.y-_lengthUnit*5/8, _lengthUnit*5/8, _lengthUnit)];
  312 + graduationLabel.adjustsFontSizeToFitWidth = YES;
  313 + graduationLabel.tag = labelTag;
  314 + graduationLabel.font = [UIFont systemFontOfSize:ceil(_lengthUnit)];
  315 + graduationLabel.textColor = [UIColor orangeColor];
  316 + graduationLabel.text = [NSString stringWithFormat:@"%.0f",_valueDivider*section];
  317 + [self addSubview:graduationLabel];
  318 + if (_isShowGraduation) {
  319 + [graduationLabel setHidden:NO];
  320 + }else{
  321 + [graduationLabel setHidden:YES];}
  322 + }
  323 +
  324 +}
  325 +
  326 +- (NSArray *)getWebPointWithLength:(CGFloat)length angleArray:(NSArray *)angleArray {
  327 + NSMutableArray *pointArray = [NSMutableArray array];
  328 + for (NSNumber *angleNumber in angleArray) {
  329 + CGFloat angle = [angleNumber floatValue];
  330 + CGFloat x = _centerX + length*cos(angle);
  331 + CGFloat y = _centerY + length*sin(angle);
  332 + [pointArray addObject:[NSValue valueWithCGPoint:CGPointMake(x,y)]];
  333 + }
  334 + return pointArray;
  335 +
  336 +}
  337 +
  338 +- (NSArray *)getLengthArrayWithCircleNum:(int)plotCircles {
  339 + NSMutableArray *lengthArray = [NSMutableArray array];
  340 + CGFloat length = 0;
  341 + for (int i = 0; i < plotCircles; i++) {
  342 + length += _lengthUnit;
  343 + [lengthArray addObject:[NSNumber numberWithFloat:length]];
  344 + }
  345 + return lengthArray;
  346 +}
  347 +
  348 +- (CGFloat)getMaxWidthLabelFromArray:(NSArray *)keyArray withFontSize:(CGFloat)size {
  349 + CGFloat maxWidth = 0;
  350 + for (NSString *str in keyArray) {
  351 + CGSize detailSize = [str sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:_fontSize]}];
  352 + maxWidth = MAX(maxWidth, detailSize.width);
  353 + }
  354 + return maxWidth;
  355 +}
  356 +
  357 +- (CGFloat)getMaxValueFromArray:(NSArray *)valueArray {
  358 + CGFloat max = _maxValue;
  359 + for (NSNumber *valueNum in valueArray) {
  360 + CGFloat valueFloat = [valueNum floatValue];
  361 + max = MAX(valueFloat, max);
  362 + }
  363 + return ceil(max);
  364 +}
  365 +
  366 +
  367 +
  368 +@end
  1 +//
  2 +// PNRadarChartDataItem.h
  3 +// PNChartDemo
  4 +//
  5 +// Created by Lei on 15/7/1.
  6 +// Copyright (c) 2015年 kevinzhow. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface PNRadarChartDataItem : NSObject
  12 +
  13 ++ (instancetype)dataItemWithValue:(CGFloat)value
  14 + description:(NSString *)description;
  15 +
  16 +@property (nonatomic) CGFloat value;
  17 +@property (nonatomic,copy) NSString *textDescription;
  18 +
  19 +@end
  1 +//
  2 +// PNRadarChartDataItem.m
  3 +// PNChartDemo
  4 +//
  5 +// Created by Lei on 15/7/1.
  6 +// Copyright (c) 2015年 kevinzhow. All rights reserved.
  7 +//
  8 +
  9 +#import "PNRadarChartDataItem.h"
  10 +
  11 +@implementation PNRadarChartDataItem
  12 +
  13 ++ (instancetype)dataItemWithValue:(CGFloat)value
  14 + description:(NSString *)description {
  15 + PNRadarChartDataItem *item = [PNRadarChartDataItem new];
  16 + item.value = value;
  17 + item.textDescription = description;
  18 + return item;
  19 +}
  20 +
  21 +- (void)setValue:(CGFloat)value {
  22 + if (value<0) {
  23 + _value = 0;
  24 + NSLog(@"Value value can not be negative");
  25 + }
  26 + _value = value;
  27 +}
  28 +
  29 +@end
@@ -35,6 +35,8 @@ @@ -35,6 +35,8 @@
35 9FE15DF8190BB014004129F5 /* PNChartLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DE9190BB014004129F5 /* PNChartLabel.m */; }; 35 9FE15DF8190BB014004129F5 /* PNChartLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DE9190BB014004129F5 /* PNChartLabel.m */; };
36 9FE15DFA190BB014004129F5 /* PNColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DEE190BB014004129F5 /* PNColor.m */; }; 36 9FE15DFA190BB014004129F5 /* PNColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DEE190BB014004129F5 /* PNColor.m */; };
37 A9C75FA61A9F1DA900A54638 /* PNGenericChart.m in Sources */ = {isa = PBXBuildFile; fileRef = A9C75FA51A9F1DA900A54638 /* PNGenericChart.m */; }; 37 A9C75FA61A9F1DA900A54638 /* PNGenericChart.m in Sources */ = {isa = PBXBuildFile; fileRef = A9C75FA51A9F1DA900A54638 /* PNGenericChart.m */; };
  38 + ABD79D021B43700800A7C300 /* PNRadarChart.m in Sources */ = {isa = PBXBuildFile; fileRef = ABD79D011B43700800A7C300 /* PNRadarChart.m */; };
  39 + ABD79D051B43CF8000A7C300 /* PNRadarChartDataItem.m in Sources */ = {isa = PBXBuildFile; fileRef = ABD79D041B43CF8000A7C300 /* PNRadarChartDataItem.m */; };
38 E2C3ED5773A1409C8367CC70 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BA6321352024B1FBA0158B0 /* libPods.a */; }; 40 E2C3ED5773A1409C8367CC70 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BA6321352024B1FBA0158B0 /* libPods.a */; };
39 /* End PBXBuildFile section */ 41 /* End PBXBuildFile section */
40 42
@@ -103,6 +105,10 @@ @@ -103,6 +105,10 @@
103 9FE15DEE190BB014004129F5 /* PNColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNColor.m; sourceTree = "<group>"; }; 105 9FE15DEE190BB014004129F5 /* PNColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNColor.m; sourceTree = "<group>"; };
104 A9C75FA41A9F1DA900A54638 /* PNGenericChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNGenericChart.h; sourceTree = "<group>"; }; 106 A9C75FA41A9F1DA900A54638 /* PNGenericChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNGenericChart.h; sourceTree = "<group>"; };
105 A9C75FA51A9F1DA900A54638 /* PNGenericChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNGenericChart.m; sourceTree = "<group>"; }; 107 A9C75FA51A9F1DA900A54638 /* PNGenericChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNGenericChart.m; sourceTree = "<group>"; };
  108 + ABD79D001B43700800A7C300 /* PNRadarChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNRadarChart.h; sourceTree = "<group>"; };
  109 + ABD79D011B43700800A7C300 /* PNRadarChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNRadarChart.m; sourceTree = "<group>"; };
  110 + ABD79D031B43CF8000A7C300 /* PNRadarChartDataItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNRadarChartDataItem.h; sourceTree = "<group>"; };
  111 + ABD79D041B43CF8000A7C300 /* PNRadarChartDataItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNRadarChartDataItem.m; sourceTree = "<group>"; };
106 B0A0D7DDAB496680487BF1E5 /* libPods-PNChartTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PNChartTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 112 B0A0D7DDAB496680487BF1E5 /* libPods-PNChartTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PNChartTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
107 EFE4F6360943ED4001072124 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; }; 113 EFE4F6360943ED4001072124 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
108 FB2FFF68E5C9B426137EDD03 /* Pods-PNChartTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PNChartTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PNChartTests/Pods-PNChartTests.debug.xcconfig"; sourceTree = "<group>"; }; 114 FB2FFF68E5C9B426137EDD03 /* Pods-PNChartTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PNChartTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PNChartTests/Pods-PNChartTests.debug.xcconfig"; sourceTree = "<group>"; };
@@ -263,6 +269,10 @@ @@ -263,6 +269,10 @@
263 91177ED7198DFAC400017E27 /* PNPieChartDataItem.m */, 269 91177ED7198DFAC400017E27 /* PNPieChartDataItem.m */,
264 A9C75FA41A9F1DA900A54638 /* PNGenericChart.h */, 270 A9C75FA41A9F1DA900A54638 /* PNGenericChart.h */,
265 A9C75FA51A9F1DA900A54638 /* PNGenericChart.m */, 271 A9C75FA51A9F1DA900A54638 /* PNGenericChart.m */,
  272 + ABD79D001B43700800A7C300 /* PNRadarChart.h */,
  273 + ABD79D011B43700800A7C300 /* PNRadarChart.m */,
  274 + ABD79D031B43CF8000A7C300 /* PNRadarChartDataItem.h */,
  275 + ABD79D041B43CF8000A7C300 /* PNRadarChartDataItem.m */,
266 ); 276 );
267 path = PNChart; 277 path = PNChart;
268 sourceTree = "<group>"; 278 sourceTree = "<group>";
@@ -434,11 +444,13 @@ @@ -434,11 +444,13 @@
434 files = ( 444 files = (
435 91177EDE198DFAC400017E27 /* PNLineChart.m in Sources */, 445 91177EDE198DFAC400017E27 /* PNLineChart.m in Sources */,
436 9FE15DF8190BB014004129F5 /* PNChartLabel.m in Sources */, 446 9FE15DF8190BB014004129F5 /* PNChartLabel.m in Sources */,
  447 + ABD79D021B43700800A7C300 /* PNRadarChart.m in Sources */,
437 91177EDC198DFAC400017E27 /* PNCircleChart.m in Sources */, 448 91177EDC198DFAC400017E27 /* PNCircleChart.m in Sources */,
438 9FE15DFA190BB014004129F5 /* PNColor.m in Sources */, 449 9FE15DFA190BB014004129F5 /* PNColor.m in Sources */,
439 91177ED8198DFAC400017E27 /* PNBar.m in Sources */, 450 91177ED8198DFAC400017E27 /* PNBar.m in Sources */,
440 91177EE2198DFAC400017E27 /* PNLineChartDataItem.m in Sources */, 451 91177EE2198DFAC400017E27 /* PNLineChartDataItem.m in Sources */,
441 0AF7A8AF182AAEEF003645C4 /* PCChartViewController.m in Sources */, 452 0AF7A8AF182AAEEF003645C4 /* PCChartViewController.m in Sources */,
  453 + ABD79D051B43CF8000A7C300 /* PNRadarChartDataItem.m in Sources */,
442 0A29228A1A423FB300A42BC4 /* PNScatterChartDataItem.m in Sources */, 454 0A29228A1A423FB300A42BC4 /* PNScatterChartDataItem.m in Sources */,
443 A9C75FA61A9F1DA900A54638 /* PNGenericChart.m in Sources */, 455 A9C75FA61A9F1DA900A54638 /* PNGenericChart.m in Sources */,
444 91177EE6198DFAC400017E27 /* PNPieChartDataItem.m in Sources */, 456 91177EE6198DFAC400017E27 /* PNPieChartDataItem.m in Sources */,
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?> 1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="9Rt-UT-IxH"> 2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="9Rt-UT-IxH">
3 <dependencies> 3 <dependencies>
4 <deployment identifier="iOS"/> 4 <deployment identifier="iOS"/>
5 - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/> 5 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
6 </dependencies> 6 </dependencies>
7 <scenes> 7 <scenes>
8 <!--PNChart--> 8 <!--PNChart-->
@@ -45,13 +45,13 @@ @@ -45,13 +45,13 @@
45 </connections> 45 </connections>
46 </switch> 46 </switch>
47 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Percentage" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IKu-qh-ksi"> 47 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Percentage" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IKu-qh-ksi">
48 - <rect key="frame" x="16" y="528" width="88" height="21"/> 48 + <rect key="frame" x="16" y="528" width="121" height="21"/>
49 <fontDescription key="fontDescription" type="system" pointSize="17"/> 49 <fontDescription key="fontDescription" type="system" pointSize="17"/>
50 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> 50 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
51 <nil key="highlightedColor"/> 51 <nil key="highlightedColor"/>
52 </label> 52 </label>
53 - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Show Labels" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ifm-a9-Wkq"> 53 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Show Labels" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ifm-a9-Wkq">
54 - <rect key="frame" x="211" y="527" width="99" height="21"/> 54 + <rect key="frame" x="192" y="527" width="118" height="21"/>
55 <fontDescription key="fontDescription" type="system" pointSize="17"/> 55 <fontDescription key="fontDescription" type="system" pointSize="17"/>
56 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> 56 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
57 <nil key="highlightedColor"/> 57 <nil key="highlightedColor"/>
@@ -188,6 +188,26 @@ @@ -188,6 +188,26 @@
188 <segue destination="Tha-Wr-sPW" kind="push" identifier="scatterChart" id="V7s-JV-4Nx"/> 188 <segue destination="Tha-Wr-sPW" kind="push" identifier="scatterChart" id="V7s-JV-4Nx"/>
189 </connections> 189 </connections>
190 </tableViewCell> 190 </tableViewCell>
  191 + <tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="Sjk-AS-XhW" style="IBUITableViewCellStyleDefault" id="bev-fA-J4Q">
  192 + <rect key="frame" x="0.0" y="196" width="320" height="44"/>
  193 + <autoresizingMask key="autoresizingMask"/>
  194 + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bev-fA-J4Q" id="nSV-Wu-TAu">
  195 + <rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
  196 + <autoresizingMask key="autoresizingMask"/>
  197 + <subviews>
  198 + <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="RadarChart" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Sjk-AS-XhW">
  199 + <rect key="frame" x="15" y="0.0" width="270" height="43"/>
  200 + <autoresizingMask key="autoresizingMask"/>
  201 + <fontDescription key="fontDescription" type="system" pointSize="18"/>
  202 + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
  203 + <nil key="highlightedColor"/>
  204 + </label>
  205 + </subviews>
  206 + </tableViewCellContentView>
  207 + <connections>
  208 + <segue destination="Tha-Wr-sPW" kind="push" identifier="radarChart" id="4D9-t3-nzn"/>
  209 + </connections>
  210 + </tableViewCell>
191 </cells> 211 </cells>
192 </tableViewSection> 212 </tableViewSection>
193 </sections> 213 </sections>
@@ -220,6 +240,6 @@ @@ -220,6 +240,6 @@
220 <simulatedScreenMetrics key="destination" type="retina4"/> 240 <simulatedScreenMetrics key="destination" type="retina4"/>
221 </simulatedMetricsContainer> 241 </simulatedMetricsContainer>
222 <inferredMetricsTieBreakers> 242 <inferredMetricsTieBreakers>
223 - <segue reference="V7s-JV-4Nx"/> 243 + <segue reference="pvQ-oy-a9a"/>
224 </inferredMetricsTieBreakers> 244 </inferredMetricsTieBreakers>
225 </document> 245 </document>
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 @property (nonatomic) PNCircleChart * circleChart; 17 @property (nonatomic) PNCircleChart * circleChart;
18 @property (nonatomic) PNPieChart *pieChart; 18 @property (nonatomic) PNPieChart *pieChart;
19 @property (nonatomic) PNScatterChart *scatterChart; 19 @property (nonatomic) PNScatterChart *scatterChart;
  20 +@property (nonatomic) PNRadarChart *radarChart;
20 21
21 @property (weak, nonatomic) IBOutlet UILabel *titleLabel; 22 @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
22 23
@@ -206,6 +206,29 @@ @@ -206,6 +206,29 @@
206 self.changeValueButton.hidden = YES; 206 self.changeValueButton.hidden = YES;
207 [self.view addSubview:self.scatterChart]; 207 [self.view addSubview:self.scatterChart];
208 } 208 }
  209 + else if ([self.title isEqualToString:@"Radar Chart"])
  210 + {
  211 + self.titleLabel.text = @"Radar Chart";
  212 +
  213 + self.leftSwitch.hidden = NO;
  214 + self.rightSwitch.hidden = NO;
  215 + self.leftLabel.hidden = NO;
  216 + self.rightLabel.hidden = NO;
  217 + self.leftLabel.text = @"Labels Style";
  218 + self.rightLabel.text = @"Graduation";
  219 +
  220 + NSArray *items = @[[PNRadarChartDataItem dataItemWithValue:3 description:@"Art"],
  221 + [PNRadarChartDataItem dataItemWithValue:2 description:@"Math"],
  222 + [PNRadarChartDataItem dataItemWithValue:8 description:@"Sports"],
  223 + [PNRadarChartDataItem dataItemWithValue:5 description:@"Literature"],
  224 + [PNRadarChartDataItem dataItemWithValue:4 description:@"Other"],
  225 + ];
  226 + self.radarChart = [[PNRadarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 300.0) items:items valueDivider:1];
  227 + [self.radarChart strokeChart];
  228 +
  229 + [self.view addSubview:self.radarChart];
  230 + }
  231 +
209 } 232 }
210 233
211 234
@@ -310,6 +333,15 @@ @@ -310,6 +333,15 @@
310 } 333 }
311 [self.pieChart strokeChart]; 334 [self.pieChart strokeChart];
312 } 335 }
  336 + if ([self.title isEqualToString:@"Radar Chart"]){
  337 + UISwitch *showLabels = (UISwitch*) sender;
  338 + if (showLabels.on) {
  339 + self.radarChart.isShowGraduation = NO;
  340 + }else{
  341 + self.radarChart.isShowGraduation = YES;
  342 + }
  343 + [self.radarChart strokeChart];
  344 + }
313 } 345 }
314 346
315 - (IBAction)leftSwitchChanged:(id)sender { 347 - (IBAction)leftSwitchChanged:(id)sender {
@@ -322,5 +354,14 @@ @@ -322,5 +354,14 @@
322 } 354 }
323 [self.pieChart strokeChart]; 355 [self.pieChart strokeChart];
324 } 356 }
  357 + if ([self.title isEqualToString:@"Radar Chart"]){
  358 + UISwitch *showRelative = (UISwitch*) sender;
  359 + if (showRelative.on) {
  360 + self.radarChart.labelStyle = PNRadarChartLabelStyleHorizontal;
  361 + }else{
  362 + self.radarChart.labelStyle = PNRadarChartLabelStyleCircle;
  363 + }
  364 + [self.radarChart strokeChart];
  365 + }
325 } 366 }
326 @end 367 @end
@@ -45,6 +45,11 @@ @@ -45,6 +45,11 @@
45 //Add scatter chart 45 //Add scatter chart
46 46
47 viewController.title = @"Scatter Chart"; 47 viewController.title = @"Scatter Chart";
  48 + }else if ([segue.identifier isEqualToString:@"radarChart"])
  49 + {
  50 + //Add radar chart
  51 +
  52 + viewController.title = @"Radar Chart";
48 } 53 }
49 } 54 }
50 55