kevinzhow

Lots of new API for Bar Chart

1 -//  
2 -// PNBarChart.h  
3 -// PNChartDemo  
4 -//  
5 -// Created by kevin on 11/7/13.  
6 -// Copyright (c) 2013年 kevinzhow. All rights reserved.  
7 -//  
8 -  
9 -#import <UIKit/UIKit.h>  
10 -#import "PNChartDelegate.h"  
11 -  
12 -#define chartMargin 10  
13 -#define xLabelMargin 15  
14 -#define yLabelMargin 15  
15 -#define yLabelHeight 11  
16 -#define xLabelHeight 20  
17 -  
18 -@interface PNBarChart : UIView  
19 -  
20 -/**  
21 - * This method will call and stroke the line in animation  
22 - */  
23 -  
24 -- (void)strokeChart;  
25 -  
26 -@property (nonatomic) NSArray *xLabels;  
27 -@property (nonatomic) NSArray *yLabels;  
28 -@property (nonatomic) NSArray *yValues;  
29 -@property (nonatomic) CGFloat xLabelWidth;  
30 -@property (nonatomic) int yValueMax;  
31 -@property (nonatomic) UIColor *strokeColor;  
32 -@property (nonatomic) NSArray *strokeColors;  
33 -@property (nonatomic) UIColor *barBackgroundColor;  
34 -@property (nonatomic) BOOL showLabel;  
35 -  
36 -@property (nonatomic, retain) id<PNChartDelegate> delegate;  
37 -@end  
1 -//  
2 -// PNBarChart.m  
3 -// PNChartDemo  
4 -//  
5 -// Created by kevin on 11/7/13.  
6 -// Copyright (c) 2013年 kevinzhow. All rights reserved.  
7 -//  
8 -  
9 -#import "PNBarChart.h"  
10 -#import "PNColor.h"  
11 -#import "PNChartLabel.h"  
12 -#import "PNBar.h"  
13 -  
14 -@interface PNBarChart () {  
15 - NSMutableArray *_bars;  
16 - NSMutableArray *_labels;  
17 -}  
18 -  
19 -- (UIColor *)barColorAtIndex:(NSUInteger)index;  
20 -@end  
21 -  
22 -@implementation PNBarChart  
23 -  
24 -- (id)initWithFrame:(CGRect)frame  
25 -{  
26 - self = [super initWithFrame:frame];  
27 -  
28 - if (self) {  
29 - // Initialization code  
30 - self.backgroundColor = [UIColor whiteColor];  
31 - self.clipsToBounds = YES;  
32 - _showLabel = YES;  
33 - _barBackgroundColor = PNLightGrey;  
34 - _labels = [NSMutableArray array];  
35 - _bars = [NSMutableArray array];  
36 - }  
37 -  
38 - return self;  
39 -}  
40 -  
41 -  
42 -- (void)setYValues:(NSArray *)yValues  
43 -{  
44 - _yValues = yValues;  
45 - [self setYLabels:yValues];  
46 -  
47 - _xLabelWidth = (self.frame.size.width - chartMargin * 2) / [_yValues count];  
48 -}  
49 -  
50 -  
51 -- (void)setYLabels:(NSArray *)yLabels  
52 -{  
53 - NSInteger max = 0;  
54 -  
55 - for (NSString *valueString in yLabels) {  
56 - NSInteger value = [valueString integerValue];  
57 -  
58 - if (value > max) {  
59 - max = value;  
60 - }  
61 - }  
62 -  
63 - //Min value for Y label  
64 - if (max < 5) {  
65 - max = 5;  
66 - }  
67 -  
68 - _yValueMax = (int)max;  
69 -}  
70 -  
71 -  
72 -- (void)setXLabels:(NSArray *)xLabels  
73 -{  
74 - _xLabels = xLabels;  
75 -  
76 - if (_showLabel) {  
77 - _xLabelWidth = (self.frame.size.width - chartMargin * 2) / [xLabels count];  
78 - }  
79 -}  
80 -  
81 -  
82 -- (void)setStrokeColor:(UIColor *)strokeColor  
83 -{  
84 - _strokeColor = strokeColor;  
85 -}  
86 -  
87 -  
88 -- (void)strokeChart  
89 -{  
90 - [self viewCleanupForCollection:_labels];  
91 -  
92 - for (int index = 0; index < _xLabels.count; index++) {  
93 - NSString *labelText = _xLabels[index];  
94 - PNChartLabel *label = [[PNChartLabel alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin), self.frame.size.height - xLabelHeight - chartMargin, _xLabelWidth, xLabelHeight)];  
95 - [label setTextAlignment:NSTextAlignmentCenter];  
96 - label.text = labelText;  
97 - [_labels addObject:label];  
98 - [self addSubview:label];  
99 - }  
100 -  
101 - [self viewCleanupForCollection:_bars];  
102 -  
103 - CGFloat chartCavanHeight = self.frame.size.height - chartMargin * 2 - xLabelHeight * 2;  
104 - NSInteger index = 0;  
105 -  
106 - for (NSString *valueString in _yValues) {  
107 - float value = [valueString floatValue];  
108 -  
109 - float grade = (float)value / (float)_yValueMax;  
110 - PNBar *bar;  
111 -  
112 - if (_showLabel) {  
113 - bar = [[PNBar alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin + _xLabelWidth * 0.25), self.frame.size.height - chartCavanHeight - xLabelHeight - chartMargin, _xLabelWidth * 0.5, chartCavanHeight)];  
114 - }  
115 - else {  
116 - bar = [[PNBar alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin + _xLabelWidth * 0.25), self.frame.size.height - chartCavanHeight, _xLabelWidth * 0.6, chartCavanHeight)];  
117 - }  
118 -  
119 - bar.backgroundColor = _barBackgroundColor;  
120 - bar.barColor = [self barColorAtIndex:index];  
121 - bar.grade = grade;  
122 - bar.tag = index;  
123 - [_bars addObject:bar];  
124 - [self addSubview:bar];  
125 -  
126 - index += 1;  
127 - }  
128 -}  
129 -  
130 -  
131 -- (void)viewCleanupForCollection:(NSMutableArray *)array  
132 -{  
133 - if (array.count) {  
134 - [array makeObjectsPerformSelector:@selector(removeFromSuperview)];  
135 - [array removeAllObjects];  
136 - }  
137 -}  
138 -  
139 -  
140 -#pragma mark - Class extension methods  
141 -  
142 -- (UIColor *)barColorAtIndex:(NSUInteger)index  
143 -{  
144 - if ([self.strokeColors count] == [self.yValues count]) {  
145 - return self.strokeColors[index];  
146 - }  
147 - else {  
148 - return self.strokeColor;  
149 - }  
150 -}  
151 -  
152 -  
153 -#pragma mark - Touch detection  
154 -  
155 -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event  
156 -{  
157 - [self touchPoint:touches withEvent:event];  
158 - [super touchesBegan:touches withEvent:event];  
159 -}  
160 -  
161 -  
162 -- (void)touchPoint:(NSSet *)touches withEvent:(UIEvent *)event  
163 -{  
164 - //Get the point user touched  
165 - UITouch *touch = [touches anyObject];  
166 - CGPoint touchPoint = [touch locationInView:self];  
167 - UIView *subview = [self hitTest:touchPoint withEvent:nil];  
168 -  
169 - if ([subview isKindOfClass:[PNBar class]] && [self.delegate respondsToSelector:@selector(userClickedOnBarCharIndex:)]) {  
170 - [self.delegate userClickedOnBarCharIndex:subview.tag];  
171 - }  
172 -}  
173 -  
174 -  
175 -@end  
@@ -16,4 +16,6 @@ @@ -16,4 +16,6 @@
16 @property (nonatomic) float grade; 16 @property (nonatomic) float grade;
17 @property (nonatomic) CAShapeLayer *chartLine; 17 @property (nonatomic) CAShapeLayer *chartLine;
18 @property (nonatomic) UIColor *barColor; 18 @property (nonatomic) UIColor *barColor;
  19 +@property (nonatomic) CGFloat barRadius;
  20 +
19 @end 21 @end
@@ -24,12 +24,18 @@ @@ -24,12 +24,18 @@
24 _chartLine.strokeEnd = 0.0; 24 _chartLine.strokeEnd = 0.0;
25 self.clipsToBounds = YES; 25 self.clipsToBounds = YES;
26 [self.layer addSublayer:_chartLine]; 26 [self.layer addSublayer:_chartLine];
27 - self.layer.cornerRadius = 2.0; 27 + self.barRadius = 2.0;
28 } 28 }
29 29
30 return self; 30 return self;
31 } 31 }
32 32
  33 +-(void)setBarRadius:(CGFloat)barRadius
  34 +{
  35 + _barRadius = barRadius;
  36 + self.layer.cornerRadius = _barRadius;
  37 +}
  38 +
33 39
34 - (void)setGrade:(float)grade 40 - (void)setGrade:(float)grade
35 { 41 {
  1 +//
  2 +// PNBarChart.h
  3 +// PNChartDemo
  4 +//
  5 +// Created by kevin on 11/7/13.
  6 +// Copyright (c) 2013年 kevinzhow. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "PNChartDelegate.h"
  11 +
  12 +#define xLabelMargin 15
  13 +#define yLabelMargin 15
  14 +#define yLabelHeight 11
  15 +#define xLabelHeight 20
  16 +
  17 +typedef NSString *(^PNyLabelFromatter)(CGFloat yLabelValue);
  18 +
  19 +@interface PNBarChart : UIView
  20 +
  21 +/**
  22 + * This method will call and stroke the line in animation
  23 + */
  24 +
  25 +- (void)strokeChart;
  26 +
  27 +@property (nonatomic) NSArray *xLabels;
  28 +@property (nonatomic) NSArray *yLabels;
  29 +@property (nonatomic) NSArray *yValues;
  30 +@property (nonatomic) CGFloat xLabelWidth;
  31 +@property (nonatomic) int yValueMax;
  32 +@property (nonatomic) UIColor *strokeColor;
  33 +@property (nonatomic) NSArray *strokeColors;
  34 +
  35 +
  36 +/*
  37 + chartMargin changes chart margin
  38 + */
  39 +@property (nonatomic) CGFloat yChartLabelWidth;
  40 +
  41 +/*
  42 + yLabelFormatter will format the ylabel text
  43 + */
  44 +
  45 +@property (copy) PNyLabelFromatter yLabelFormatter;
  46 +
  47 +/*
  48 + chartMargin changes chart margin
  49 + */
  50 +@property (nonatomic) CGFloat chartMargin;
  51 +
  52 +/*
  53 + showLabelDefines if the Labels should be deplay
  54 + */
  55 +@property (nonatomic) BOOL showLabel;
  56 +
  57 +/*
  58 + showChartBorder if the chart border Line should be deplay
  59 + */
  60 +@property (nonatomic) BOOL showChartBorder;
  61 +
  62 +/*
  63 + chartBottomLine the Line at the chart bottom
  64 + */
  65 +@property (nonatomic) CAShapeLayer * chartBottomLine;
  66 +
  67 +/*
  68 + chartLeftLine the Line at the chart left
  69 + */
  70 +@property (nonatomic) CAShapeLayer * chartLeftLine;
  71 +
  72 +/*
  73 + barRadius changes the bar corner radius
  74 + */
  75 +@property (nonatomic) CGFloat barRadius;
  76 +
  77 +/*
  78 + barWidth changes the width of the bar
  79 + */
  80 +@property (nonatomic) CGFloat barWidth;
  81 +
  82 +/*
  83 + labelMarginTop changes the width of the bar
  84 + */
  85 +@property (nonatomic) CGFloat labelMarginTop;
  86 +
  87 +/*
  88 + barBackgroundColor changes the bar background color
  89 + */
  90 +@property (nonatomic) UIColor * barBackgroundColor;
  91 +
  92 +/*
  93 + labelTextColor changes the bar label text color
  94 + */
  95 +@property (nonatomic) UIColor * labelTextColor;
  96 +
  97 +/*
  98 + labelFont changes the bar label font
  99 + */
  100 +@property (nonatomic) UIFont * labelFont;
  101 +
  102 +/*
  103 + xLabelSkip define the label skip number
  104 + */
  105 +@property (nonatomic) NSInteger xLabelSkip;
  106 +
  107 +/*
  108 + yLabelSum define the label skip number
  109 + */
  110 +@property (nonatomic) NSInteger yLabelSum;
  111 +
  112 +/*
  113 + yMaxValue define the max value of the chart
  114 + */
  115 +@property (nonatomic) CGFloat yMaxValue;
  116 +
  117 +@property (nonatomic, retain) id<PNChartDelegate> delegate;
  118 +
  119 +@end
  1 +//
  2 +// PNBarChart.m
  3 +// PNChartDemo
  4 +//
  5 +// Created by kevin on 11/7/13.
  6 +// Copyright (c) 2013年 kevinzhow. All rights reserved.
  7 +//
  8 +
  9 +#import "PNBarChart.h"
  10 +#import "PNColor.h"
  11 +#import "PNChartLabel.h"
  12 +#import "PNBar.h"
  13 +
  14 +@interface PNBarChart () {
  15 + NSMutableArray *_bars;
  16 + NSMutableArray *_labels;
  17 +}
  18 +
  19 +- (UIColor *)barColorAtIndex:(NSUInteger)index;
  20 +
  21 +@end
  22 +
  23 +@implementation PNBarChart
  24 +
  25 +- (id)initWithFrame:(CGRect)frame
  26 +{
  27 + self = [super initWithFrame:frame];
  28 +
  29 + if (self) {
  30 + // Initialization code
  31 + self.backgroundColor = [UIColor whiteColor];
  32 + self.clipsToBounds = YES;
  33 + _showLabel = YES;
  34 + _barBackgroundColor = PNLightGrey;
  35 + _labelTextColor = [UIColor grayColor];
  36 + _labelFont = [UIFont systemFontOfSize:11.0f];
  37 + _labels = [NSMutableArray array];
  38 + _bars = [NSMutableArray array];
  39 + _xLabelSkip = 1;
  40 + _yLabelSum = 4;
  41 + _labelMarginTop = 0;
  42 + _chartMargin = 15.0;
  43 + _barRadius = 2.0;
  44 + _showChartBorder = NO;
  45 + _yChartLabelWidth = 18;
  46 + }
  47 +
  48 + return self;
  49 +}
  50 +
  51 +
  52 +- (void)setYValues:(NSArray *)yValues
  53 +{
  54 + _yValues = yValues;
  55 +
  56 + if (_yMaxValue) {
  57 + _yValueMax = _yMaxValue;
  58 + }else{
  59 + [self getYValueMax:yValues];
  60 + }
  61 +
  62 +
  63 + _xLabelWidth = (self.frame.size.width - _chartMargin * 2) / [_yValues count];
  64 +}
  65 +
  66 +- (void)getYValueMax:(NSArray *)yLabels
  67 +{
  68 + NSInteger max = 0;
  69 +
  70 + for (NSString *valueString in yLabels) {
  71 + NSInteger value = [valueString integerValue];
  72 +
  73 + if (value > max) {
  74 + max = value;
  75 + }
  76 + }
  77 +
  78 + //Min value for Y label
  79 + if (max < 5) {
  80 + max = 5;
  81 + }
  82 +
  83 + _yValueMax = (int)max;
  84 +}
  85 +
  86 +
  87 +- (void)setYLabels:(NSArray *)yLabels
  88 +{
  89 +
  90 +}
  91 +
  92 +
  93 +- (void)setXLabels:(NSArray *)xLabels
  94 +{
  95 + _xLabels = xLabels;
  96 +
  97 + if (_showLabel) {
  98 + _xLabelWidth = (self.frame.size.width - _chartMargin * 2) / [xLabels count];
  99 + }
  100 +}
  101 +
  102 +
  103 +- (void)setStrokeColor:(UIColor *)strokeColor
  104 +{
  105 + _strokeColor = strokeColor;
  106 +}
  107 +
  108 +
  109 +- (void)strokeChart
  110 +{
  111 + [self viewCleanupForCollection:_labels];
  112 + //Add Labels
  113 + if (_showLabel) {
  114 + //Add x labels
  115 + int labelAddCount = 0;
  116 + for (int index = 0; index < _xLabels.count; index++) {
  117 + labelAddCount += 1;
  118 +
  119 + if (labelAddCount == _xLabelSkip) {
  120 + NSString *labelText = _xLabels[index];
  121 + PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectZero];
  122 + label.font = _labelFont;
  123 + label.textColor = _labelTextColor;
  124 + [label setTextAlignment:NSTextAlignmentCenter];
  125 + label.text = labelText;
  126 + NSLog(@"Label text is %@",labelText);
  127 + [label sizeToFit];
  128 + CGFloat labelXPosition;
  129 + if (label.frame.size.width < _xLabelWidth) {
  130 + labelXPosition = (index * _xLabelWidth + _chartMargin + _xLabelWidth /2.0 );
  131 + }else{
  132 + labelXPosition = (index * _xLabelWidth + _chartMargin + label.frame.size.width /2.0 );
  133 + }
  134 +
  135 + label.center = CGPointMake(labelXPosition,
  136 + self.frame.size.height - xLabelHeight - _chartMargin + label.frame.size.height /2.0 + _labelMarginTop);
  137 + labelAddCount = 0;
  138 +
  139 + [_labels addObject:label];
  140 + [self addSubview:label];
  141 + }
  142 + }
  143 +
  144 + //Add y labels
  145 +
  146 + float yLabelSectionHeight = (self.frame.size.height - _chartMargin * 2 - xLabelHeight) / _yLabelSum;
  147 +
  148 + for (int index = 0; index < _yLabelSum; index++) {
  149 +
  150 + NSString *labelText = _yLabelFormatter((float)_yValueMax * ( (_yLabelSum - index) / (float)_yLabelSum ));
  151 +
  152 + PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0,
  153 + yLabelSectionHeight * index + _chartMargin - yLabelHeight/2.0,
  154 + _yChartLabelWidth,
  155 + yLabelHeight)];
  156 + label.font = _labelFont;
  157 + label.textColor = _labelTextColor;
  158 + [label setTextAlignment:NSTextAlignmentRight];
  159 + label.text = labelText;
  160 +
  161 + [_labels addObject:label];
  162 + [self addSubview:label];
  163 +
  164 + }
  165 + }
  166 +
  167 +
  168 + [self viewCleanupForCollection:_bars];
  169 +
  170 +
  171 + //Add bars
  172 + CGFloat chartCavanHeight = self.frame.size.height - _chartMargin * 2 - xLabelHeight;
  173 + NSInteger index = 0;
  174 +
  175 + for (NSString *valueString in _yValues) {
  176 + float value = [valueString floatValue];
  177 +
  178 + float grade = (float)value / (float)_yValueMax;
  179 + PNBar *bar;
  180 + CGFloat barWidth;
  181 + CGFloat barXPosition;
  182 +
  183 + if (_barWidth) {
  184 + barWidth = _barWidth;
  185 + barXPosition = index * _xLabelWidth + _chartMargin + _xLabelWidth /2.0 - _barWidth /2.0;
  186 + }else{
  187 + barXPosition = index * _xLabelWidth + _chartMargin + _xLabelWidth * 0.25;
  188 + if (_showLabel) {
  189 + barWidth = _xLabelWidth * 0.5;
  190 +
  191 + }
  192 + else {
  193 + barWidth = _xLabelWidth * 0.6;
  194 +
  195 + }
  196 + }
  197 +
  198 + bar = [[PNBar alloc] initWithFrame:CGRectMake(barXPosition, //Bar X position
  199 + self.frame.size.height - chartCavanHeight - xLabelHeight - _chartMargin, //Bar Y position
  200 + barWidth, // Bar witdh
  201 + chartCavanHeight)]; //Bar height
  202 +
  203 + //Change Bar Radius
  204 + bar.barRadius = _barRadius;
  205 +
  206 + //Change Bar Background color
  207 + bar.backgroundColor = _barBackgroundColor;
  208 +
  209 + //Bar StrokColor First
  210 + if (self.strokeColor) {
  211 + bar.barColor = self.strokeColor;
  212 + }else{
  213 + bar.barColor = [self barColorAtIndex:index];
  214 + }
  215 +
  216 + //Height Of Bar
  217 + bar.grade = grade;
  218 +
  219 + //For Click Index
  220 + bar.tag = index;
  221 +
  222 + [_bars addObject:bar];
  223 + [self addSubview:bar];
  224 +
  225 + index += 1;
  226 + }
  227 +
  228 + //Add chart border lines
  229 +
  230 + if (_showChartBorder) {
  231 + _chartBottomLine = [CAShapeLayer layer];
  232 + _chartBottomLine.lineCap = kCALineCapButt;
  233 + _chartBottomLine.fillColor = [[UIColor whiteColor] CGColor];
  234 + _chartBottomLine.lineWidth = 1.0;
  235 + _chartBottomLine.strokeEnd = 0.0;
  236 +
  237 + UIBezierPath *progressline = [UIBezierPath bezierPath];
  238 +
  239 + [progressline moveToPoint:CGPointMake(_chartMargin, self.frame.size.height - xLabelHeight - _chartMargin)];
  240 + [progressline addLineToPoint:CGPointMake(self.frame.size.width - _chartMargin, self.frame.size.height - xLabelHeight - _chartMargin)];
  241 +
  242 + [progressline setLineWidth:1.0];
  243 + [progressline setLineCapStyle:kCGLineCapSquare];
  244 + _chartBottomLine.path = progressline.CGPath;
  245 +
  246 +
  247 + _chartBottomLine.strokeColor = PNLightGrey.CGColor;
  248 +
  249 +
  250 + CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
  251 + pathAnimation.duration = 0.5;
  252 + pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  253 + pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
  254 + pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
  255 + [_chartBottomLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
  256 +
  257 + _chartBottomLine.strokeEnd = 1.0;
  258 +
  259 + [self.layer addSublayer:_chartBottomLine];
  260 +
  261 + //Add left Chart Line
  262 +
  263 + _chartLeftLine = [CAShapeLayer layer];
  264 + _chartLeftLine.lineCap = kCALineCapButt;
  265 + _chartLeftLine.fillColor = [[UIColor whiteColor] CGColor];
  266 + _chartLeftLine.lineWidth = 1.0;
  267 + _chartLeftLine.strokeEnd = 0.0;
  268 +
  269 + UIBezierPath *progressLeftline = [UIBezierPath bezierPath];
  270 +
  271 + [progressLeftline moveToPoint:CGPointMake(_chartMargin, self.frame.size.height - xLabelHeight - _chartMargin)];
  272 + [progressLeftline addLineToPoint:CGPointMake(_chartMargin, _chartMargin)];
  273 +
  274 + [progressLeftline setLineWidth:1.0];
  275 + [progressLeftline setLineCapStyle:kCGLineCapSquare];
  276 + _chartLeftLine.path = progressLeftline.CGPath;
  277 +
  278 +
  279 + _chartLeftLine.strokeColor = PNLightGrey.CGColor;
  280 +
  281 +
  282 + CABasicAnimation *pathLeftAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
  283 + pathLeftAnimation.duration = 0.5;
  284 + pathLeftAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  285 + pathLeftAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
  286 + pathLeftAnimation.toValue = [NSNumber numberWithFloat:1.0f];
  287 + [_chartLeftLine addAnimation:pathLeftAnimation forKey:@"strokeEndAnimation"];
  288 +
  289 + _chartLeftLine.strokeEnd = 1.0;
  290 +
  291 + [self.layer addSublayer:_chartLeftLine];
  292 + }
  293 +}
  294 +
  295 +
  296 +- (void)viewCleanupForCollection:(NSMutableArray *)array
  297 +{
  298 + if (array.count) {
  299 + [array makeObjectsPerformSelector:@selector(removeFromSuperview)];
  300 + [array removeAllObjects];
  301 + }
  302 +}
  303 +
  304 +
  305 +#pragma mark - Class extension methods
  306 +
  307 +- (UIColor *)barColorAtIndex:(NSUInteger)index
  308 +{
  309 + if ([self.strokeColors count] == [self.yValues count]) {
  310 + return self.strokeColors[index];
  311 + }
  312 + else {
  313 + return self.strokeColor;
  314 + }
  315 +}
  316 +
  317 +
  318 +#pragma mark - Touch detection
  319 +
  320 +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  321 +{
  322 + [self touchPoint:touches withEvent:event];
  323 + [super touchesBegan:touches withEvent:event];
  324 +}
  325 +
  326 +
  327 +- (void)touchPoint:(NSSet *)touches withEvent:(UIEvent *)event
  328 +{
  329 + //Get the point user touched
  330 + UITouch *touch = [touches anyObject];
  331 + CGPoint touchPoint = [touch locationInView:self];
  332 + UIView *subview = [self hitTest:touchPoint withEvent:nil];
  333 +
  334 + if ([subview isKindOfClass:[PNBar class]] && [self.delegate respondsToSelector:@selector(userClickedOnBarCharIndex:)]) {
  335 + [self.delegate userClickedOnBarCharIndex:subview.tag];
  336 + }
  337 +}
  338 +
  339 +
  340 +@end
@@ -17,13 +17,10 @@ @@ -17,13 +17,10 @@
17 17
18 if (self) { 18 if (self) {
19 // Initialization code 19 // Initialization code
20 - [self setLineBreakMode:NSLineBreakByWordWrapping]; 20 +
21 - [self setMinimumScaleFactor:11.0f];  
22 - [self setNumberOfLines:0];  
23 [self setFont:[UIFont boldSystemFontOfSize:11.0f]]; 21 [self setFont:[UIFont boldSystemFontOfSize:11.0f]];
24 - [self setTextColor:PNDeepGrey];  
25 self.backgroundColor = [UIColor clearColor]; 22 self.backgroundColor = [UIColor clearColor];
26 - [self setTextAlignment:NSTextAlignmentLeft]; 23 + [self setTextAlignment:NSTextAlignmentCenter];
27 self.userInteractionEnabled = YES; 24 self.userInteractionEnabled = YES;
28 } 25 }
29 26
@@ -11,4 +11,5 @@ @@ -11,4 +11,5 @@
11 + (PNLineChartDataItem *)dataItemWithY:(CGFloat)y; 11 + (PNLineChartDataItem *)dataItemWithY:(CGFloat)y;
12 12
13 @property (readonly) CGFloat y; // should be within the y range 13 @property (readonly) CGFloat y; // should be within the y range
  14 +
14 @end 15 @end
@@ -22,15 +22,15 @@ @@ -22,15 +22,15 @@
22 0AF7A891182AA9F6003645C4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0AF7A88F182AA9F6003645C4 /* InfoPlist.strings */; }; 22 0AF7A891182AA9F6003645C4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0AF7A88F182AA9F6003645C4 /* InfoPlist.strings */; };
23 0AF7A893182AA9F6003645C4 /* PNChartDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A892182AA9F6003645C4 /* PNChartDemoTests.m */; }; 23 0AF7A893182AA9F6003645C4 /* PNChartDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A892182AA9F6003645C4 /* PNChartDemoTests.m */; };
24 0AF7A8AF182AAEEF003645C4 /* PCChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A8AE182AAEEF003645C4 /* PCChartViewController.m */; }; 24 0AF7A8AF182AAEEF003645C4 /* PCChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A8AE182AAEEF003645C4 /* PCChartViewController.m */; };
25 - 9F02DE5018C05E9A00CDED9A /* PNBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F02DE3F18C05E9A00CDED9A /* PNBar.m */; };  
26 - 9F02DE5118C05E9A00CDED9A /* PNBarChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F02DE4118C05E9A00CDED9A /* PNBarChart.m */; };  
27 - 9F02DE5218C05E9A00CDED9A /* PNChartLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F02DE4518C05E9A00CDED9A /* PNChartLabel.m */; };  
28 - 9F02DE5318C05E9A00CDED9A /* PNCircleChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F02DE4718C05E9A00CDED9A /* PNCircleChart.m */; };  
29 - 9F02DE5418C05E9A00CDED9A /* PNColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F02DE4918C05E9A00CDED9A /* PNColor.m */; };  
30 - 9F02DE5518C05E9A00CDED9A /* PNLineChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F02DE4B18C05E9A00CDED9A /* PNLineChart.m */; };  
31 - 9F02DE5618C05E9A00CDED9A /* PNLineChartData.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F02DE4D18C05E9A00CDED9A /* PNLineChartData.m */; };  
32 - 9F02DE5718C05E9A00CDED9A /* PNLineChartDataItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F02DE4F18C05E9A00CDED9A /* PNLineChartDataItem.m */; };  
33 9FA23B10184A5944002DBBA4 /* PCChartsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FA23B0F184A5944002DBBA4 /* PCChartsTableViewController.m */; }; 25 9FA23B10184A5944002DBBA4 /* PCChartsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FA23B0F184A5944002DBBA4 /* PCChartsTableViewController.m */; };
  26 + 9FE15DF6190BB014004129F5 /* PNBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DE3190BB014004129F5 /* PNBar.m */; };
  27 + 9FE15DF7190BB014004129F5 /* PNBarChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DE5190BB014004129F5 /* PNBarChart.m */; };
  28 + 9FE15DF8190BB014004129F5 /* PNChartLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DE9190BB014004129F5 /* PNChartLabel.m */; };
  29 + 9FE15DF9190BB014004129F5 /* PNCircleChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DEC190BB014004129F5 /* PNCircleChart.m */; };
  30 + 9FE15DFA190BB014004129F5 /* PNColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DEE190BB014004129F5 /* PNColor.m */; };
  31 + 9FE15DFB190BB014004129F5 /* PNLineChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DF1190BB014004129F5 /* PNLineChart.m */; };
  32 + 9FE15DFC190BB014004129F5 /* PNLineChartData.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DF3190BB014004129F5 /* PNLineChartData.m */; };
  33 + 9FE15DFD190BB014004129F5 /* PNLineChartDataItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FE15DF5190BB014004129F5 /* PNLineChartDataItem.m */; };
34 E2C3ED5773A1409C8367CC70 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BA6321352024B1FBA0158B0 /* libPods.a */; }; 34 E2C3ED5773A1409C8367CC70 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BA6321352024B1FBA0158B0 /* libPods.a */; };
35 /* End PBXBuildFile section */ 35 /* End PBXBuildFile section */
36 36
@@ -66,26 +66,26 @@ @@ -66,26 +66,26 @@
66 0AF7A8AD182AAEEF003645C4 /* PCChartViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCChartViewController.h; sourceTree = "<group>"; }; 66 0AF7A8AD182AAEEF003645C4 /* PCChartViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCChartViewController.h; sourceTree = "<group>"; };
67 0AF7A8AE182AAEEF003645C4 /* PCChartViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PCChartViewController.m; sourceTree = "<group>"; }; 67 0AF7A8AE182AAEEF003645C4 /* PCChartViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PCChartViewController.m; sourceTree = "<group>"; };
68 3BA6321352024B1FBA0158B0 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 68 3BA6321352024B1FBA0158B0 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
69 - 9F02DE3E18C05E9A00CDED9A /* PNBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNBar.h; sourceTree = "<group>"; };  
70 - 9F02DE3F18C05E9A00CDED9A /* PNBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNBar.m; sourceTree = "<group>"; };  
71 - 9F02DE4018C05E9A00CDED9A /* PNBarChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNBarChart.h; sourceTree = "<group>"; };  
72 - 9F02DE4118C05E9A00CDED9A /* PNBarChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNBarChart.m; sourceTree = "<group>"; };  
73 - 9F02DE4218C05E9A00CDED9A /* PNChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNChart.h; sourceTree = "<group>"; };  
74 - 9F02DE4318C05E9A00CDED9A /* PNChartDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNChartDelegate.h; sourceTree = "<group>"; };  
75 - 9F02DE4418C05E9A00CDED9A /* PNChartLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNChartLabel.h; sourceTree = "<group>"; };  
76 - 9F02DE4518C05E9A00CDED9A /* PNChartLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNChartLabel.m; sourceTree = "<group>"; };  
77 - 9F02DE4618C05E9A00CDED9A /* PNCircleChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNCircleChart.h; sourceTree = "<group>"; };  
78 - 9F02DE4718C05E9A00CDED9A /* PNCircleChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNCircleChart.m; sourceTree = "<group>"; };  
79 - 9F02DE4818C05E9A00CDED9A /* PNColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNColor.h; sourceTree = "<group>"; };  
80 - 9F02DE4918C05E9A00CDED9A /* PNColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNColor.m; sourceTree = "<group>"; };  
81 - 9F02DE4A18C05E9A00CDED9A /* PNLineChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNLineChart.h; sourceTree = "<group>"; };  
82 - 9F02DE4B18C05E9A00CDED9A /* PNLineChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNLineChart.m; sourceTree = "<group>"; };  
83 - 9F02DE4C18C05E9A00CDED9A /* PNLineChartData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNLineChartData.h; sourceTree = "<group>"; };  
84 - 9F02DE4D18C05E9A00CDED9A /* PNLineChartData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNLineChartData.m; sourceTree = "<group>"; };  
85 - 9F02DE4E18C05E9A00CDED9A /* PNLineChartDataItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNLineChartDataItem.h; sourceTree = "<group>"; };  
86 - 9F02DE4F18C05E9A00CDED9A /* PNLineChartDataItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNLineChartDataItem.m; sourceTree = "<group>"; };  
87 9FA23B0E184A5944002DBBA4 /* PCChartsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCChartsTableViewController.h; sourceTree = "<group>"; }; 69 9FA23B0E184A5944002DBBA4 /* PCChartsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCChartsTableViewController.h; sourceTree = "<group>"; };
88 9FA23B0F184A5944002DBBA4 /* PCChartsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PCChartsTableViewController.m; sourceTree = "<group>"; }; 70 9FA23B0F184A5944002DBBA4 /* PCChartsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PCChartsTableViewController.m; sourceTree = "<group>"; };
  71 + 9FE15DE2190BB014004129F5 /* PNBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNBar.h; sourceTree = "<group>"; };
  72 + 9FE15DE3190BB014004129F5 /* PNBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNBar.m; sourceTree = "<group>"; };
  73 + 9FE15DE4190BB014004129F5 /* PNBarChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNBarChart.h; sourceTree = "<group>"; };
  74 + 9FE15DE5190BB014004129F5 /* PNBarChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNBarChart.m; sourceTree = "<group>"; };
  75 + 9FE15DE6190BB014004129F5 /* PNChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNChart.h; sourceTree = "<group>"; };
  76 + 9FE15DE7190BB014004129F5 /* PNChartDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNChartDelegate.h; sourceTree = "<group>"; };
  77 + 9FE15DE8190BB014004129F5 /* PNChartLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNChartLabel.h; sourceTree = "<group>"; };
  78 + 9FE15DE9190BB014004129F5 /* PNChartLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNChartLabel.m; sourceTree = "<group>"; };
  79 + 9FE15DEB190BB014004129F5 /* PNCircleChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNCircleChart.h; sourceTree = "<group>"; };
  80 + 9FE15DEC190BB014004129F5 /* PNCircleChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNCircleChart.m; sourceTree = "<group>"; };
  81 + 9FE15DED190BB014004129F5 /* PNColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNColor.h; sourceTree = "<group>"; };
  82 + 9FE15DEE190BB014004129F5 /* PNColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNColor.m; sourceTree = "<group>"; };
  83 + 9FE15DF0190BB014004129F5 /* PNLineChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNLineChart.h; sourceTree = "<group>"; };
  84 + 9FE15DF1190BB014004129F5 /* PNLineChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNLineChart.m; sourceTree = "<group>"; };
  85 + 9FE15DF2190BB014004129F5 /* PNLineChartData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNLineChartData.h; sourceTree = "<group>"; };
  86 + 9FE15DF3190BB014004129F5 /* PNLineChartData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNLineChartData.m; sourceTree = "<group>"; };
  87 + 9FE15DF4190BB014004129F5 /* PNLineChartDataItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNLineChartDataItem.h; sourceTree = "<group>"; };
  88 + 9FE15DF5190BB014004129F5 /* PNLineChartDataItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNLineChartDataItem.m; sourceTree = "<group>"; };
89 F161CF4F7A8C4BD2AB65FB4F /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = "<group>"; }; 89 F161CF4F7A8C4BD2AB65FB4F /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = "<group>"; };
90 /* End PBXFileReference section */ 90 /* End PBXFileReference section */
91 91
@@ -118,7 +118,7 @@ @@ -118,7 +118,7 @@
118 0AF7A85B182AA9F5003645C4 = { 118 0AF7A85B182AA9F5003645C4 = {
119 isa = PBXGroup; 119 isa = PBXGroup;
120 children = ( 120 children = (
121 - 9F02DE3D18C05E9A00CDED9A /* PNChart */, 121 + 9FE15DE0190BB014004129F5 /* PNChart */,
122 0AF7A86D182AA9F6003645C4 /* PNChartDemo */, 122 0AF7A86D182AA9F6003645C4 /* PNChartDemo */,
123 0AF7A88C182AA9F6003645C4 /* PNChartDemoTests */, 123 0AF7A88C182AA9F6003645C4 /* PNChartDemoTests */,
124 0AF7A866182AA9F6003645C4 /* Frameworks */, 124 0AF7A866182AA9F6003645C4 /* Frameworks */,
@@ -202,31 +202,55 @@ @@ -202,31 +202,55 @@
202 name = PCChartViewController; 202 name = PCChartViewController;
203 sourceTree = "<group>"; 203 sourceTree = "<group>";
204 }; 204 };
205 - 9F02DE3D18C05E9A00CDED9A /* PNChart */ = { 205 + 9FE15DE0190BB014004129F5 /* PNChart */ = {
206 isa = PBXGroup; 206 isa = PBXGroup;
207 children = ( 207 children = (
208 - 9F02DE3E18C05E9A00CDED9A /* PNBar.h */, 208 + 9FE15DE1190BB014004129F5 /* PNBarChart */,
209 - 9F02DE3F18C05E9A00CDED9A /* PNBar.m */, 209 + 9FE15DE6190BB014004129F5 /* PNChart.h */,
210 - 9F02DE4018C05E9A00CDED9A /* PNBarChart.h */, 210 + 9FE15DE7190BB014004129F5 /* PNChartDelegate.h */,
211 - 9F02DE4118C05E9A00CDED9A /* PNBarChart.m */, 211 + 9FE15DE8190BB014004129F5 /* PNChartLabel.h */,
212 - 9F02DE4218C05E9A00CDED9A /* PNChart.h */, 212 + 9FE15DE9190BB014004129F5 /* PNChartLabel.m */,
213 - 9F02DE4318C05E9A00CDED9A /* PNChartDelegate.h */, 213 + 9FE15DEA190BB014004129F5 /* PNCircleChart */,
214 - 9F02DE4418C05E9A00CDED9A /* PNChartLabel.h */, 214 + 9FE15DED190BB014004129F5 /* PNColor.h */,
215 - 9F02DE4518C05E9A00CDED9A /* PNChartLabel.m */, 215 + 9FE15DEE190BB014004129F5 /* PNColor.m */,
216 - 9F02DE4618C05E9A00CDED9A /* PNCircleChart.h */, 216 + 9FE15DEF190BB014004129F5 /* PNLineChart */,
217 - 9F02DE4718C05E9A00CDED9A /* PNCircleChart.m */,  
218 - 9F02DE4818C05E9A00CDED9A /* PNColor.h */,  
219 - 9F02DE4918C05E9A00CDED9A /* PNColor.m */,  
220 - 9F02DE4A18C05E9A00CDED9A /* PNLineChart.h */,  
221 - 9F02DE4B18C05E9A00CDED9A /* PNLineChart.m */,  
222 - 9F02DE4C18C05E9A00CDED9A /* PNLineChartData.h */,  
223 - 9F02DE4D18C05E9A00CDED9A /* PNLineChartData.m */,  
224 - 9F02DE4E18C05E9A00CDED9A /* PNLineChartDataItem.h */,  
225 - 9F02DE4F18C05E9A00CDED9A /* PNLineChartDataItem.m */,  
226 ); 217 );
227 path = PNChart; 218 path = PNChart;
228 sourceTree = "<group>"; 219 sourceTree = "<group>";
229 }; 220 };
  221 + 9FE15DE1190BB014004129F5 /* PNBarChart */ = {
  222 + isa = PBXGroup;
  223 + children = (
  224 + 9FE15DE2190BB014004129F5 /* PNBar.h */,
  225 + 9FE15DE3190BB014004129F5 /* PNBar.m */,
  226 + 9FE15DE4190BB014004129F5 /* PNBarChart.h */,
  227 + 9FE15DE5190BB014004129F5 /* PNBarChart.m */,
  228 + );
  229 + path = PNBarChart;
  230 + sourceTree = "<group>";
  231 + };
  232 + 9FE15DEA190BB014004129F5 /* PNCircleChart */ = {
  233 + isa = PBXGroup;
  234 + children = (
  235 + 9FE15DEB190BB014004129F5 /* PNCircleChart.h */,
  236 + 9FE15DEC190BB014004129F5 /* PNCircleChart.m */,
  237 + );
  238 + path = PNCircleChart;
  239 + sourceTree = "<group>";
  240 + };
  241 + 9FE15DEF190BB014004129F5 /* PNLineChart */ = {
  242 + isa = PBXGroup;
  243 + children = (
  244 + 9FE15DF0190BB014004129F5 /* PNLineChart.h */,
  245 + 9FE15DF1190BB014004129F5 /* PNLineChart.m */,
  246 + 9FE15DF2190BB014004129F5 /* PNLineChartData.h */,
  247 + 9FE15DF3190BB014004129F5 /* PNLineChartData.m */,
  248 + 9FE15DF4190BB014004129F5 /* PNLineChartDataItem.h */,
  249 + 9FE15DF5190BB014004129F5 /* PNLineChartDataItem.m */,
  250 + );
  251 + path = PNLineChart;
  252 + sourceTree = "<group>";
  253 + };
230 /* End PBXGroup section */ 254 /* End PBXGroup section */
231 255
232 /* Begin PBXNativeTarget section */ 256 /* Begin PBXNativeTarget section */
@@ -360,17 +384,17 @@ @@ -360,17 +384,17 @@
360 isa = PBXSourcesBuildPhase; 384 isa = PBXSourcesBuildPhase;
361 buildActionMask = 2147483647; 385 buildActionMask = 2147483647;
362 files = ( 386 files = (
363 - 9F02DE5518C05E9A00CDED9A /* PNLineChart.m in Sources */, 387 + 9FE15DFB190BB014004129F5 /* PNLineChart.m in Sources */,
364 - 9F02DE5218C05E9A00CDED9A /* PNChartLabel.m in Sources */, 388 + 9FE15DF8190BB014004129F5 /* PNChartLabel.m in Sources */,
365 - 9F02DE5418C05E9A00CDED9A /* PNColor.m in Sources */, 389 + 9FE15DFA190BB014004129F5 /* PNColor.m in Sources */,
366 - 9F02DE5018C05E9A00CDED9A /* PNBar.m in Sources */, 390 + 9FE15DF6190BB014004129F5 /* PNBar.m in Sources */,
367 0AF7A8AF182AAEEF003645C4 /* PCChartViewController.m in Sources */, 391 0AF7A8AF182AAEEF003645C4 /* PCChartViewController.m in Sources */,
368 - 9F02DE5718C05E9A00CDED9A /* PNLineChartDataItem.m in Sources */, 392 + 9FE15DFD190BB014004129F5 /* PNLineChartDataItem.m in Sources */,
369 9FA23B10184A5944002DBBA4 /* PCChartsTableViewController.m in Sources */, 393 9FA23B10184A5944002DBBA4 /* PCChartsTableViewController.m in Sources */,
370 - 9F02DE5318C05E9A00CDED9A /* PNCircleChart.m in Sources */, 394 + 9FE15DF9190BB014004129F5 /* PNCircleChart.m in Sources */,
371 0AF7A874182AA9F6003645C4 /* main.m in Sources */, 395 0AF7A874182AA9F6003645C4 /* main.m in Sources */,
372 - 9F02DE5618C05E9A00CDED9A /* PNLineChartData.m in Sources */, 396 + 9FE15DFC190BB014004129F5 /* PNLineChartData.m in Sources */,
373 - 9F02DE5118C05E9A00CDED9A /* PNBarChart.m in Sources */, 397 + 9FE15DF7190BB014004129F5 /* PNBarChart.m in Sources */,
374 0AF7A878182AA9F6003645C4 /* PCAppDelegate.m in Sources */, 398 0AF7A878182AA9F6003645C4 /* PCAppDelegate.m in Sources */,
375 ); 399 );
376 runOnlyForDeploymentPostprocessing = 0; 400 runOnlyForDeploymentPostprocessing = 0;
@@ -106,6 +106,12 @@ @@ -106,6 +106,12 @@
106 106
107 PNBarChart * barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; 107 PNBarChart * barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)];
108 barChart.backgroundColor = [UIColor clearColor]; 108 barChart.backgroundColor = [UIColor clearColor];
  109 + barChart.yLabelFormatter = ^(CGFloat yValue){
  110 + CGFloat yValueParsed = yValue;
  111 + NSString * labelText = [NSString stringWithFormat:@"%1.f",yValueParsed];
  112 + return labelText;
  113 + };
  114 + barChart.labelMarginTop = 5.0;
109 [barChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]]; 115 [barChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]];
110 [barChart setYValues:@[@1,@24,@12,@18,@30,@10,@21]]; 116 [barChart setYValues:@[@1,@24,@12,@18,@30,@10,@21]];
111 [barChart setStrokeColors:@[PNGreen,PNGreen,PNRed,PNGreen,PNGreen,PNYellow,PNGreen]]; 117 [barChart setStrokeColors:@[PNGreen,PNGreen,PNRed,PNGreen,PNGreen,PNYellow,PNGreen]];
@@ -129,18 +135,13 @@ @@ -129,18 +135,13 @@
129 circleChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; 135 circleChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0];
130 circleChartLabel.textAlignment = NSTextAlignmentCenter; 136 circleChartLabel.textAlignment = NSTextAlignmentCenter;
131 137
132 - PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:[NSNumber numberWithInt:100] andCurrent:[NSNumber numberWithInt:60] andClockwise:YES andShadow:NO]; 138 + 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];
133 circleChart.backgroundColor = [UIColor clearColor]; 139 circleChart.backgroundColor = [UIColor clearColor];
134 [circleChart setStrokeColor:PNGreen]; 140 [circleChart setStrokeColor:PNGreen];
135 [circleChart strokeChart]; 141 [circleChart strokeChart];
136 142
137 - PNCircleChart * circleChart2 = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:[NSNumber numberWithInt:100] andCurrent:[NSNumber numberWithInt:90] andClockwise:YES andShadow:YES];  
138 - circleChart2.backgroundColor = [UIColor clearColor];  
139 - [circleChart2 setStrokeColor:PNBlue];  
140 - [circleChart2 strokeChart];  
141 -  
142 [viewController.view addSubview:circleChartLabel]; 143 [viewController.view addSubview:circleChartLabel];
143 - [viewController.view addSubview:circleChart2]; 144 +
144 [viewController.view addSubview:circleChart]; 145 [viewController.view addSubview:circleChart];
145 viewController.title = @"Circle Chart"; 146 viewController.title = @"Circle Chart";
146 147