onevcat

Add initWithCoder for bar chart

@@ -22,33 +22,47 @@ @@ -22,33 +22,47 @@
22 22
23 @implementation PNBarChart 23 @implementation PNBarChart
24 24
  25 +- (id)initWithCoder:(NSCoder *)aDecoder
  26 +{
  27 + self = [super initWithCoder:aDecoder];
  28 +
  29 + if (self) {
  30 + [self setupDefaultValues];
  31 + }
  32 + return self;
  33 +}
  34 +
25 - (id)initWithFrame:(CGRect)frame 35 - (id)initWithFrame:(CGRect)frame
26 { 36 {
27 self = [super initWithFrame:frame]; 37 self = [super initWithFrame:frame];
28 38
29 if (self) { 39 if (self) {
30 - self.backgroundColor = [UIColor whiteColor]; 40 + [self setupDefaultValues];
31 - self.clipsToBounds = YES;  
32 - _showLabel = YES;  
33 - _barBackgroundColor = PNLightGrey;  
34 - _labelTextColor = [UIColor grayColor];  
35 - _labelFont = [UIFont systemFontOfSize:11.0f];  
36 - _xChartLabels = [NSMutableArray array];  
37 - _yChartLabels = [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 - _rotateForXAxisText = false;  
47 } 41 }
48 42
49 return self; 43 return self;
50 } 44 }
51 45
  46 +- (void)setupDefaultValues
  47 +{
  48 + self.backgroundColor = [UIColor whiteColor];
  49 + self.clipsToBounds = YES;
  50 + _showLabel = YES;
  51 + _barBackgroundColor = PNLightGrey;
  52 + _labelTextColor = [UIColor grayColor];
  53 + _labelFont = [UIFont systemFontOfSize:11.0f];
  54 + _xChartLabels = [NSMutableArray array];
  55 + _yChartLabels = [NSMutableArray array];
  56 + _bars = [NSMutableArray array];
  57 + _xLabelSkip = 1;
  58 + _yLabelSum = 4;
  59 + _labelMarginTop = 0;
  60 + _chartMargin = 15.0;
  61 + _barRadius = 2.0;
  62 + _showChartBorder = NO;
  63 + _yChartLabelWidth = 18;
  64 + _rotateForXAxisText = false;
  65 +}
52 66
53 - (void)setYValues:(NSArray *)yValues 67 - (void)setYValues:(NSArray *)yValues
54 { 68 {