Gianmaria Dal Maistro

Merge branch 'master' of github.com:jerrygdm/PNChart into HideValues-PieChart

Conflicts:
	PNChart/PNPieChart.h
	PNChart/PNPieChart.m
@@ -16,7 +16,7 @@ Pod::Spec.new do |s| @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
16 # 16 #
17 17
18 s.name = "PNChart" 18 s.name = "PNChart"
19 - s.version = "0.8.5" 19 + s.version = "0.8.6"
20 s.summary = "A simple and beautiful chart lib with animation used in Piner for iOS" 20 s.summary = "A simple and beautiful chart lib with animation used in Piner for iOS"
21 21
22 s.description = <<-DESC 22 s.description = <<-DESC
@@ -90,7 +90,7 @@ Pod::Spec.new do |s| @@ -90,7 +90,7 @@ Pod::Spec.new do |s|
90 # Supports git, hg, bzr, svn and HTTP. 90 # Supports git, hg, bzr, svn and HTTP.
91 # 91 #
92 92
93 - s.source = { :git => "https://github.com/kevinzhow/PNChart.git", :tag => "0.8.5" } 93 + s.source = { :git => "https://github.com/kevinzhow/PNChart.git", :tag => s.version }
94 94
95 95
96 # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 96 # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
@@ -26,6 +26,9 @@ @@ -26,6 +26,9 @@
26 @property (nonatomic) CAShapeLayer *gradeLayer; 26 @property (nonatomic) CAShapeLayer *gradeLayer;
27 @property (nonatomic) CATextLayer* textLayer; 27 @property (nonatomic) CATextLayer* textLayer;
28 28
  29 +/** Text color for all bars in the chart. */
  30 +@property (nonatomic) UIColor * labelTextColor;
  31 +
29 @property (nonatomic, assign) BOOL isNegative; //!< 是否是负数 32 @property (nonatomic, assign) BOOL isNegative; //!< 是否是负数
30 @property (nonatomic, assign) BOOL isShowNumber; //!< 是否显示numbers 33 @property (nonatomic, assign) BOOL isShowNumber; //!< 是否显示numbers
31 @end 34 @end
@@ -181,7 +181,7 @@ @@ -181,7 +181,7 @@
181 _textLayer = [[CATextLayer alloc]init]; 181 _textLayer = [[CATextLayer alloc]init];
182 [_textLayer setString:@"0"]; 182 [_textLayer setString:@"0"];
183 [_textLayer setAlignmentMode:kCAAlignmentCenter]; 183 [_textLayer setAlignmentMode:kCAAlignmentCenter];
184 - [_textLayer setForegroundColor:[[UIColor colorWithRed:178/255.0 green:178/255. blue:178/255.0 alpha:1.0] CGColor]]; 184 + [_textLayer setForegroundColor:[_labelTextColor CGColor]];
185 _textLayer.hidden = YES; 185 _textLayer.hidden = YES;
186 186
187 } 187 }
@@ -189,6 +189,11 @@ @@ -189,6 +189,11 @@
189 return _textLayer; 189 return _textLayer;
190 } 190 }
191 191
  192 +- (void) setLabelTextColor:(UIColor *)labelTextColor {
  193 + _labelTextColor = labelTextColor;
  194 + [_textLayer setForegroundColor:[_labelTextColor CGColor]];
  195 +}
  196 +
192 -(void)setGradeFrame:(CGFloat)grade startPosY:(CGFloat)startPosY 197 -(void)setGradeFrame:(CGFloat)grade startPosY:(CGFloat)startPosY
193 { 198 {
194 CGFloat textheigt = self.bounds.size.height*self.grade; 199 CGFloat textheigt = self.bounds.size.height*self.grade;
@@ -52,7 +52,10 @@ typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue); @@ -52,7 +52,10 @@ typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue);
52 /** Suffix to y label values, none if unset. */ 52 /** Suffix to y label values, none if unset. */
53 @property (nonatomic) NSString *yLabelSuffix; 53 @property (nonatomic) NSString *yLabelSuffix;
54 54
55 -@property (nonatomic) CGFloat chartMargin; 55 +@property (nonatomic) CGFloat chartMarginLeft;
  56 +@property (nonatomic) CGFloat chartMarginRight;
  57 +@property (nonatomic) CGFloat chartMarginTop;
  58 +@property (nonatomic) CGFloat chartMarginBottom;
56 59
57 /** Controls whether labels should be displayed. */ 60 /** Controls whether labels should be displayed. */
58 @property (nonatomic) BOOL showLabel; 61 @property (nonatomic) BOOL showLabel;
@@ -60,6 +63,8 @@ typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue); @@ -60,6 +63,8 @@ typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue);
60 /** Controls whether the chart border line should be displayed. */ 63 /** Controls whether the chart border line should be displayed. */
61 @property (nonatomic) BOOL showChartBorder; 64 @property (nonatomic) BOOL showChartBorder;
62 65
  66 +@property (nonatomic) UIColor *chartBorderColor;
  67 +
63 /** Controls whether the chart Horizontal separator should be displayed. */ 68 /** Controls whether the chart Horizontal separator should be displayed. */
64 @property (nonatomic, assign) BOOL showLevelLine; 69 @property (nonatomic, assign) BOOL showLevelLine;
65 70
This diff is collapsed. Click to expand it.
@@ -13,7 +13,9 @@ @@ -13,7 +13,9 @@
13 typedef NS_ENUM (NSUInteger, PNChartFormatType) { 13 typedef NS_ENUM (NSUInteger, PNChartFormatType) {
14 PNChartFormatTypePercent, 14 PNChartFormatTypePercent,
15 PNChartFormatTypeDollar, 15 PNChartFormatTypeDollar,
16 - PNChartFormatTypeNone 16 + PNChartFormatTypeNone,
  17 + PNChartFormatTypeDecimal,
  18 + PNChartFormatTypeDecimalTwoPlaces,
17 }; 19 };
18 20
19 #define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI) 21 #define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)
@@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
46 current:current 46 current:current
47 clockwise:clockwise 47 clockwise:clockwise
48 shadow:shadow 48 shadow:shadow
49 - shadowColor:PNGreen 49 + shadowColor:backgroundShadowColor
50 displayCountingLabel:displayCountingLabel 50 displayCountingLabel:displayCountingLabel
51 overrideLineWidth:@8.0f]; 51 overrideLineWidth:@8.0f];
52 52
@@ -131,6 +131,12 @@ displayCountingLabel:(BOOL)displayCountingLabel @@ -131,6 +131,12 @@ displayCountingLabel:(BOOL)displayCountingLabel
131 case PNChartFormatTypeDollar: 131 case PNChartFormatTypeDollar:
132 format = @"$%d"; 132 format = @"$%d";
133 break; 133 break;
  134 + case PNChartFormatTypeDecimal:
  135 + format = @"%.1f";
  136 + break;
  137 + case PNChartFormatTypeDecimalTwoPlaces:
  138 + format = @"%.2f";
  139 + break;
134 case PNChartFormatTypeNone: 140 case PNChartFormatTypeNone:
135 default: 141 default:
136 format = @"%d"; 142 format = @"%d";
@@ -45,11 +45,14 @@ @@ -45,11 +45,14 @@
45 @property (nonatomic) UIColor *yLabelColor; 45 @property (nonatomic) UIColor *yLabelColor;
46 @property (nonatomic) CGFloat chartCavanHeight; 46 @property (nonatomic) CGFloat chartCavanHeight;
47 @property (nonatomic) CGFloat chartCavanWidth; 47 @property (nonatomic) CGFloat chartCavanWidth;
48 -@property (nonatomic) CGFloat chartMargin;  
49 @property (nonatomic) BOOL showLabel; 48 @property (nonatomic) BOOL showLabel;
50 @property (nonatomic) BOOL showGenYLabels; 49 @property (nonatomic) BOOL showGenYLabels;
51 @property (nonatomic) BOOL thousandsSeparator; 50 @property (nonatomic) BOOL thousandsSeparator;
52 51
  52 +@property (nonatomic) CGFloat chartMarginLeft;
  53 +@property (nonatomic) CGFloat chartMarginRight;
  54 +@property (nonatomic) CGFloat chartMarginTop;
  55 +@property (nonatomic) CGFloat chartMarginBottom;
53 56
54 /** 57 /**
55 * Controls whether to show the coordinate axis. Default is NO. 58 * Controls whether to show the coordinate axis. Default is NO.
This diff is collapsed. Click to expand it.
@@ -25,6 +25,11 @@ typedef PNLineChartDataItem *(^LCLineChartDataGetter)(NSUInteger item); @@ -25,6 +25,11 @@ typedef PNLineChartDataItem *(^LCLineChartDataGetter)(NSUInteger item);
25 @property (copy) LCLineChartDataGetter getData; 25 @property (copy) LCLineChartDataGetter getData;
26 @property (strong, nonatomic) NSString *dataTitle; 26 @property (strong, nonatomic) NSString *dataTitle;
27 27
  28 +@property (nonatomic) BOOL showPointLabel;
  29 +@property (nonatomic) UIColor *pointLabelColor;
  30 +@property (nonatomic) UIFont *pointLabelFont;
  31 +@property (nonatomic) NSString *pointLabelFormat;
  32 +
28 @property (nonatomic, assign) PNLineChartPointStyle inflexionPointStyle; 33 @property (nonatomic, assign) PNLineChartPointStyle inflexionPointStyle;
29 34
30 /** 35 /**
@@ -23,6 +23,9 @@ @@ -23,6 +23,9 @@
23 _inflexionPointWidth = 6.f; 23 _inflexionPointWidth = 6.f;
24 _lineWidth = 2.f; 24 _lineWidth = 2.f;
25 _alpha = 1.f; 25 _alpha = 1.f;
  26 + _showPointLabel = NO;
  27 + _pointLabelColor = [UIColor blackColor];
  28 + _pointLabelFormat = @"%1.f";
26 } 29 }
27 30
28 @end 31 @end
@@ -9,7 +9,9 @@ @@ -9,7 +9,9 @@
9 @interface PNLineChartDataItem : NSObject 9 @interface PNLineChartDataItem : NSObject
10 10
11 + (PNLineChartDataItem *)dataItemWithY:(CGFloat)y; 11 + (PNLineChartDataItem *)dataItemWithY:(CGFloat)y;
  12 ++ (PNLineChartDataItem *)dataItemWithY:(CGFloat)y andRawY:(CGFloat)rawY;
12 13
13 @property (readonly) CGFloat y; // should be within the y range 14 @property (readonly) CGFloat y; // should be within the y range
  15 +@property (readonly) CGFloat rawY; // this is the raw value, used for point label.
14 16
15 @end 17 @end
@@ -7,9 +7,10 @@ @@ -7,9 +7,10 @@
7 7
8 @interface PNLineChartDataItem () 8 @interface PNLineChartDataItem ()
9 9
10 -- (id)initWithY:(CGFloat)y; 10 +- (id)initWithY:(CGFloat)y andRawY:(CGFloat)rawY;
11 11
12 -@property (readwrite) CGFloat y; // should be within the y range 12 +@property (readwrite) CGFloat y; // should be within the y range
  13 +@property (readwrite) CGFloat rawY; // this is the raw value, used for point label.
13 14
14 @end 15 @end
15 16
@@ -17,13 +18,18 @@ @@ -17,13 +18,18 @@
17 18
18 + (PNLineChartDataItem *)dataItemWithY:(CGFloat)y 19 + (PNLineChartDataItem *)dataItemWithY:(CGFloat)y
19 { 20 {
20 - return [[PNLineChartDataItem alloc] initWithY:y]; 21 + return [[PNLineChartDataItem alloc] initWithY:y andRawY:y];
21 } 22 }
22 23
23 -- (id)initWithY:(CGFloat)y 24 ++ (PNLineChartDataItem *)dataItemWithY:(CGFloat)y andRawY:(CGFloat)rawY {
  25 + return [[PNLineChartDataItem alloc] initWithY:y andRawY:rawY];
  26 +}
  27 +
  28 +- (id)initWithY:(CGFloat)y andRawY:(CGFloat)rawY
24 { 29 {
25 if ((self = [super init])) { 30 if ((self = [super init])) {
26 self.y = y; 31 self.y = y;
  32 + self.rawY = rawY;
27 } 33 }
28 34
29 return self; 35 return self;
@@ -32,9 +32,6 @@ @@ -32,9 +32,6 @@
32 /** Default is 1.0. */ 32 /** Default is 1.0. */
33 @property (nonatomic) NSTimeInterval duration; 33 @property (nonatomic) NSTimeInterval duration;
34 34
35 -/** show only tiles, not values or percentage */  
36 -@property (nonatomic) BOOL hideValues;  
37 -  
38 /** Show only values, this is useful when legend is present */ 35 /** Show only values, this is useful when legend is present */
39 @property (nonatomic) BOOL showOnlyValues; 36 @property (nonatomic) BOOL showOnlyValues;
40 37
@@ -47,11 +44,29 @@ @@ -47,11 +44,29 @@
47 /** Default YES. */ 44 /** Default YES. */
48 @property (nonatomic) BOOL shouldHighlightSectorOnTouch; 45 @property (nonatomic) BOOL shouldHighlightSectorOnTouch;
49 46
  47 +/** Current outer radius. Override recompute() to change this. **/
  48 +@property (nonatomic) CGFloat outerCircleRadius;
  49 +
  50 +/** Current inner radius. Override recompute() to change this. **/
  51 +@property (nonatomic) CGFloat innerCircleRadius;
  52 +
50 @property (nonatomic, weak) id<PNChartDelegate> delegate; 53 @property (nonatomic, weak) id<PNChartDelegate> delegate;
51 54
  55 +/** Update chart items. Does not update chart itself. */
  56 +- (void)updateChartData:(NSArray *)data;
  57 +
52 /** Multiple selection */ 58 /** Multiple selection */
53 @property (nonatomic, assign) BOOL enableMultipleSelection; 59 @property (nonatomic, assign) BOOL enableMultipleSelection;
54 60
  61 +/** show only tiles, not values or percentage */
  62 +@property (nonatomic) BOOL hideValues;
  63 +
55 - (void)strokeChart; 64 - (void)strokeChart;
56 65
  66 +- (void)recompute;
  67 +
  68 +<<<<<<< Updated upstream
  69 +@end
  70 +=======
57 @end 71 @end
  72 +>>>>>>> Stashed changes
@@ -15,14 +15,13 @@ @@ -15,14 +15,13 @@
15 @property (nonatomic) NSArray *items; 15 @property (nonatomic) NSArray *items;
16 @property (nonatomic) NSArray *endPercentages; 16 @property (nonatomic) NSArray *endPercentages;
17 17
18 -@property (nonatomic) CGFloat outerCircleRadius;  
19 -@property (nonatomic) CGFloat innerCircleRadius;  
20 -  
21 @property (nonatomic) UIView *contentView; 18 @property (nonatomic) UIView *contentView;
22 @property (nonatomic) CAShapeLayer *pieLayer; 19 @property (nonatomic) CAShapeLayer *pieLayer;
23 @property (nonatomic) NSMutableArray *descriptionLabels; 20 @property (nonatomic) NSMutableArray *descriptionLabels;
24 @property (strong, nonatomic) CAShapeLayer *sectorHighlight; 21 @property (strong, nonatomic) CAShapeLayer *sectorHighlight;
25 22
  23 +@property (nonatomic, strong) NSMutableDictionary *selectedItems;
  24 +
26 - (void)loadDefault; 25 - (void)loadDefault;
27 26
28 - (UILabel *)descriptionLabelForItemAtIndex:(NSUInteger)index; 27 - (UILabel *)descriptionLabelForItemAtIndex:(NSUInteger)index;
@@ -48,9 +47,9 @@ @@ -48,9 +47,9 @@
48 self = [self initWithFrame:frame]; 47 self = [self initWithFrame:frame];
49 if(self){ 48 if(self){
50 _items = [NSArray arrayWithArray:items]; 49 _items = [NSArray arrayWithArray:items];
  50 + _selectedItems = [NSMutableDictionary dictionary];
51 _outerCircleRadius = CGRectGetWidth(self.bounds) / 2; 51 _outerCircleRadius = CGRectGetWidth(self.bounds) / 2;
52 _innerCircleRadius = CGRectGetWidth(self.bounds) / 6; 52 _innerCircleRadius = CGRectGetWidth(self.bounds) / 6;
53 -  
54 _descriptionTextColor = [UIColor whiteColor]; 53 _descriptionTextColor = [UIColor whiteColor];
55 _descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:18.0]; 54 _descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:18.0];
56 _descriptionTextShadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.4]; 55 _descriptionTextShadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
@@ -88,12 +87,20 @@ @@ -88,12 +87,20 @@
88 87
89 _pieLayer = [CAShapeLayer layer]; 88 _pieLayer = [CAShapeLayer layer];
90 [_contentView.layer addSublayer:_pieLayer]; 89 [_contentView.layer addSublayer:_pieLayer];
  90 +
  91 +}
  92 +
  93 +/** Override this to change how inner attributes are computed. **/
  94 +- (void)recompute {
  95 + self.outerCircleRadius = CGRectGetWidth(self.bounds) / 2;
  96 + self.innerCircleRadius = CGRectGetWidth(self.bounds) / 6;
91 } 97 }
92 98
93 #pragma mark - 99 #pragma mark -
94 100
95 - (void)strokeChart{ 101 - (void)strokeChart{
96 [self loadDefault]; 102 [self loadDefault];
  103 + [self recompute];
97 104
98 PNPieChartDataItem *currentItem; 105 PNPieChartDataItem *currentItem;
99 for (int i = 0; i < _items.count; i++) { 106 for (int i = 0; i < _items.count; i++) {
@@ -174,6 +181,10 @@ @@ -174,6 +181,10 @@
174 return descriptionLabel; 181 return descriptionLabel;
175 } 182 }
176 183
  184 +- (void)updateChartData:(NSArray *)items {
  185 + self.items = items;
  186 +}
  187 +
177 - (PNPieChartDataItem *)dataItemForIndex:(NSUInteger)index{ 188 - (PNPieChartDataItem *)dataItemForIndex:(NSUInteger)index{
178 return self.items[index]; 189 return self.items[index];
179 } 190 }
@@ -284,15 +295,17 @@ @@ -284,15 +295,17 @@
284 while (percentage > [self endPercentageForItemAtIndex:index]) { 295 while (percentage > [self endPercentageForItemAtIndex:index]) {
285 index ++; 296 index ++;
286 } 297 }
287 - 298 +
288 if ([self.delegate respondsToSelector:@selector(userClickedOnPieIndexItem:)]) { 299 if ([self.delegate respondsToSelector:@selector(userClickedOnPieIndexItem:)]) {
289 [self.delegate userClickedOnPieIndexItem:index]; 300 [self.delegate userClickedOnPieIndexItem:index];
290 } 301 }
291 302
292 - if (self.shouldHighlightSectorOnTouch) { 303 + if (self.shouldHighlightSectorOnTouch)
293 - 304 + {
294 - if (self.sectorHighlight) { 305 + if (!self.enableMultipleSelection)
295 - [self.sectorHighlight removeFromSuperlayer]; 306 + {
  307 + if (self.sectorHighlight)
  308 + [self.sectorHighlight removeFromSuperlayer];
296 } 309 }
297 310
298 PNPieChartDataItem *currentItem = [self dataItemForIndex:index]; 311 PNPieChartDataItem *currentItem = [self dataItemForIndex:index];
@@ -305,13 +318,33 @@ @@ -305,13 +318,33 @@
305 318
306 CGFloat startPercnetage = [self startPercentageForItemAtIndex:index]; 319 CGFloat startPercnetage = [self startPercentageForItemAtIndex:index];
307 CGFloat endPercentage = [self endPercentageForItemAtIndex:index]; 320 CGFloat endPercentage = [self endPercentageForItemAtIndex:index];
308 - self.sectorHighlight = [self newCircleLayerWithRadius:_outerCircleRadius + 5 321 +
  322 + self.sectorHighlight = [self newCircleLayerWithRadius:_outerCircleRadius + 5
309 borderWidth:10 323 borderWidth:10
310 fillColor:[UIColor clearColor] 324 fillColor:[UIColor clearColor]
311 borderColor:newColor 325 borderColor:newColor
312 startPercentage:startPercnetage 326 startPercentage:startPercnetage
313 endPercentage:endPercentage]; 327 endPercentage:endPercentage];
314 - [_contentView.layer addSublayer:self.sectorHighlight]; 328 +
  329 + if (self.enableMultipleSelection)
  330 + {
  331 + NSString *dictIndex = [NSString stringWithFormat:@"%d", index];
  332 + CAShapeLayer *indexShape = [self.selectedItems valueForKey:dictIndex];
  333 + if (indexShape)
  334 + {
  335 + [indexShape removeFromSuperlayer];
  336 + [self.selectedItems removeObjectForKey:dictIndex];
  337 + }
  338 + else
  339 + {
  340 + [self.selectedItems setObject:self.sectorHighlight forKey:dictIndex];
  341 + [_contentView.layer addSublayer:self.sectorHighlight];
  342 + }
  343 + }
  344 + else
  345 + {
  346 + [_contentView.layer addSublayer:self.sectorHighlight];
  347 + }
315 } 348 }
316 } 349 }
317 350
@@ -402,7 +435,7 @@ @@ -402,7 +435,7 @@
402 x += self.legendStyle == PNLegendItemStyleStacked ? 0 : labelsize.width + beforeLabel; 435 x += self.legendStyle == PNLegendItemStyleStacked ? 0 : labelsize.width + beforeLabel;
403 y += self.legendStyle == PNLegendItemStyleStacked ? labelsize.height : 0; 436 y += self.legendStyle == PNLegendItemStyleStacked ? labelsize.height : 0;
404 437
405 - 438 +
406 totalHeight = self.legendStyle == PNLegendItemStyleSerial ? fmaxf(totalHeight, rowMaxHeight + y) : totalHeight + labelsize.height; 439 totalHeight = self.legendStyle == PNLegendItemStyleSerial ? fmaxf(totalHeight, rowMaxHeight + y) : totalHeight + labelsize.height;
407 [legendViews addObject:label]; 440 [legendViews addObject:label];
408 counter ++; 441 counter ++;
@@ -427,7 +460,7 @@ @@ -427,7 +460,7 @@
427 CGContextRef context = UIGraphicsGetCurrentContext(); 460 CGContextRef context = UIGraphicsGetCurrentContext();
428 461
429 CGContextAddArc(context, size/2, size/ 2, size/2, 0, M_PI*2, YES); 462 CGContextAddArc(context, size/2, size/ 2, size/2, 0, M_PI*2, YES);
430 - 463 +
431 464
432 //Set some fill color 465 //Set some fill color
433 CGContextSetFillColorWithColor(context, color.CGColor); 466 CGContextSetFillColorWithColor(context, color.CGColor);
@@ -448,4 +481,11 @@ @@ -448,4 +481,11 @@
448 [squareImageView setFrame:CGRectMake(originX, originY, size, size)]; 481 [squareImageView setFrame:CGRectMake(originX, originY, size, size)];
449 return squareImageView; 482 return squareImageView;
450 } 483 }
  484 +
  485 +/* Redraw the chart on autolayout */
  486 +-(void)layoutSubviews {
  487 + [super layoutSubviews];
  488 + [self strokeChart];
  489 +}
  490 +
451 @end 491 @end
1 -<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:PNChartDemo.xcodeproj'/><FileRef location='group:Pods/Pods.xcodeproj'/></Workspace> 1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<Workspace
  3 + version = "1.0">
  4 + <FileRef
  5 + location = "group:PNChartDemo.xcodeproj">
  6 + </FileRef>
  7 + <FileRef
  8 + location = "group:Pods/Pods.xcodeproj">
  9 + </FileRef>
  10 +</Workspace>
This diff is collapsed. Click to expand it.
@@ -25,12 +25,13 @@ @@ -25,12 +25,13 @@
25 @property (weak, nonatomic) IBOutlet UIButton *changeValueButton; 25 @property (weak, nonatomic) IBOutlet UIButton *changeValueButton;
26 26
27 @property (weak, nonatomic) IBOutlet UISwitch *leftSwitch; 27 @property (weak, nonatomic) IBOutlet UISwitch *leftSwitch;
  28 +@property (weak, nonatomic) IBOutlet UISwitch *centerSwitch;
28 @property (weak, nonatomic) IBOutlet UISwitch *rightSwitch; 29 @property (weak, nonatomic) IBOutlet UISwitch *rightSwitch;
29 @property (weak, nonatomic) IBOutlet UILabel *leftLabel; 30 @property (weak, nonatomic) IBOutlet UILabel *leftLabel;
30 @property (weak, nonatomic) IBOutlet UILabel *rightLabel; 31 @property (weak, nonatomic) IBOutlet UILabel *rightLabel;
31 32
32 - (IBAction)rightSwitchChanged:(id)sender; 33 - (IBAction)rightSwitchChanged:(id)sender;
33 - (IBAction)leftSwitchChanged:(id)sender; 34 - (IBAction)leftSwitchChanged:(id)sender;
34 - 35 +- (IBAction)rightSwitchChanged:(id)sender;
35 36
36 @end 37 @end
@@ -91,20 +91,34 @@ @@ -91,20 +91,34 @@
91 } 91 }
92 else if ([self.title isEqualToString:@"Bar Chart"]) 92 else if ([self.title isEqualToString:@"Bar Chart"])
93 { 93 {
  94 + static NSNumberFormatter *barChartFormatter;
  95 + if (!barChartFormatter){
  96 + barChartFormatter = [[NSNumberFormatter alloc] init];
  97 + barChartFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
  98 + barChartFormatter.allowsFloats = NO;
  99 + barChartFormatter.maximumFractionDigits = 0;
  100 + }
94 self.titleLabel.text = @"Bar Chart"; 101 self.titleLabel.text = @"Bar Chart";
95 102
96 self.barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; 103 self.barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)];
97 // self.barChart.showLabel = NO; 104 // self.barChart.showLabel = NO;
98 self.barChart.backgroundColor = [UIColor clearColor]; 105 self.barChart.backgroundColor = [UIColor clearColor];
99 self.barChart.yLabelFormatter = ^(CGFloat yValue){ 106 self.barChart.yLabelFormatter = ^(CGFloat yValue){
100 - CGFloat yValueParsed = yValue; 107 + return [barChartFormatter stringFromNumber:[NSNumber numberWithFloat:yValue]];
101 - NSString * labelText = [NSString stringWithFormat:@"%0.f",yValueParsed];  
102 - return labelText;  
103 }; 108 };
  109 +
  110 + self.barChart.yChartLabelWidth = 20.0;
  111 + self.barChart.chartMarginLeft = 30.0;
  112 + self.barChart.chartMarginRight = 10.0;
  113 + self.barChart.chartMarginTop = 5.0;
  114 + self.barChart.chartMarginBottom = 10.0;
  115 +
  116 +
104 self.barChart.labelMarginTop = 5.0; 117 self.barChart.labelMarginTop = 5.0;
105 self.barChart.showChartBorder = YES; 118 self.barChart.showChartBorder = YES;
106 [self.barChart setXLabels:@[@"2",@"3",@"4",@"5",@"2",@"3",@"4",@"5"]]; 119 [self.barChart setXLabels:@[@"2",@"3",@"4",@"5",@"2",@"3",@"4",@"5"]];
107 // self.barChart.yLabels = @[@-10,@0,@10]; 120 // self.barChart.yLabels = @[@-10,@0,@10];
  121 +// [self.barChart setYValues:@[@10000.0,@30000.0,@10000.0,@100000.0,@500000.0,@1000000.0,@1150000.0,@2150000.0]];
108 [self.barChart setYValues:@[@10.82,@1.88,@6.96,@33.93,@10.82,@1.88,@6.96,@33.93]]; 122 [self.barChart setYValues:@[@10.82,@1.88,@6.96,@33.93,@10.82,@1.88,@6.96,@33.93]];
109 [self.barChart setStrokeColors:@[PNGreen,PNGreen,PNRed,PNGreen,PNGreen,PNGreen,PNRed,PNGreen]]; 123 [self.barChart setStrokeColors:@[PNGreen,PNGreen,PNRed,PNGreen,PNGreen,PNGreen,PNRed,PNGreen]];
110 self.barChart.isGradientShow = NO; 124 self.barChart.isGradientShow = NO;
@@ -344,6 +358,15 @@ @@ -344,6 +358,15 @@
344 } 358 }
345 } 359 }
346 360
  361 +- (IBAction)centerSwitchChanged:(id)sender
  362 +{
  363 + if (self.pieChart)
  364 + {
  365 + [self.pieChart setEnableMultipleSelection:self.centerSwitch.on];
  366 + [self.pieChart strokeChart];
  367 + }
  368 +}
  369 +
347 - (IBAction)leftSwitchChanged:(id)sender { 370 - (IBAction)leftSwitchChanged:(id)sender {
348 if ([self.title isEqualToString:@"Pie Chart"]){ 371 if ([self.title isEqualToString:@"Pie Chart"]){
349 UISwitch *showRelative = (UISwitch*) sender; 372 UISwitch *showRelative = (UISwitch*) sender;
1 PODS: 1 PODS:
2 - - Expecta (0.4.2) 2 + - Expecta (1.0.2)
3 - UICountingLabel (1.2.0) 3 - UICountingLabel (1.2.0)
4 4
5 DEPENDENCIES: 5 DEPENDENCIES:
@@ -7,7 +7,7 @@ DEPENDENCIES: @@ -7,7 +7,7 @@ DEPENDENCIES:
7 - UICountingLabel (~> 1.2.0) 7 - UICountingLabel (~> 1.2.0)
8 8
9 SPEC CHECKSUMS: 9 SPEC CHECKSUMS:
10 - Expecta: 78b4e8b0c8291fa4524d7f74016b6065c2e391ec 10 + Expecta: 54e8a3530add08f4f0208c111355eda7cde74a53
11 UICountingLabel: 1db4e7d023e1762171eb226d6dff47a7a84f27aa 11 UICountingLabel: 1db4e7d023e1762171eb226d6dff47a7a84f27aa
12 12
13 COCOAPODS: 0.38.2 13 COCOAPODS: 0.38.2
@@ -10,7 +10,10 @@ A simple and beautiful chart lib with **animation** used in [Piner](https://itun @@ -10,7 +10,10 @@ A simple and beautiful chart lib with **animation** used in [Piner](https://itun
10 10
11 ## Requirements 11 ## Requirements
12 12
13 -PNChart works on iOS 6.0 (Begin with 0.8.2 supports iOS 8 and Later only, if you are working with iOS 6 and iOS 7, use 0.8.1 instead.) and later version and is compatible with ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates: 13 +PNChart works on iOS 7.0+ and is compatible with ARC projects.
  14 +If you need support for iOS 6, use PNChart <= 0.8.1. Note that 0.8.2 supports iOS 8.0+ only, 0.8.3 and newer supports iOS 7.0+.
  15 +
  16 +It depends on the following Apple frameworks, which should already be included with most Xcode templates:
14 17
15 * Foundation.framework 18 * Foundation.framework
16 * UIKit.framework 19 * UIKit.framework