kevinzhow

Merge branch 'master' of github.com:kevinzhow/PNChart

@@ -62,8 +62,10 @@ @@ -62,8 +62,10 @@
62 62
63 if (_showLabel) { 63 if (_showLabel) {
64 _xLabelWidth = (self.frame.size.width - chartMargin*2)/[xLabels count]; 64 _xLabelWidth = (self.frame.size.width - chartMargin*2)/[xLabels count];
65 - for (NSString * labelText in xLabels) { 65 +
66 - NSInteger index = [xLabels indexOfObject:labelText]; 66 + for(int index = 0; index < xLabels.count; index++)
  67 + {
  68 + NSString* labelText = xLabels[index];
67 PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin), self.frame.size.height - 30.0, _xLabelWidth, 20.0)]; 69 PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin), self.frame.size.height - 30.0, _xLabelWidth, 20.0)];
68 [label setTextAlignment:NSTextAlignmentCenter]; 70 [label setTextAlignment:NSTextAlignmentCenter];
69 label.text = labelText; 71 label.text = labelText;
@@ -77,13 +77,16 @@ @@ -77,13 +77,16 @@
77 77
78 if(_showLabel){ 78 if(_showLabel){
79 _xLabelWidth = (self.frame.size.width - chartMargin - 30.0)/[xLabels count]; 79 _xLabelWidth = (self.frame.size.width - chartMargin - 30.0)/[xLabels count];
80 - for (NSString * labelText in xLabels) { 80 +
81 - NSInteger index = [xLabels indexOfObject:labelText]; 81 + for(int index = 0; index < xLabels.count; index++)
  82 + {
  83 + NSString* labelText = xLabels[index];
82 PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake(index * _xLabelWidth + 30.0, self.frame.size.height - 30.0, _xLabelWidth, 20.0)]; 84 PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake(index * _xLabelWidth + 30.0, self.frame.size.height - 30.0, _xLabelWidth, 20.0)];
83 [label setTextAlignment:NSTextAlignmentCenter]; 85 [label setTextAlignment:NSTextAlignmentCenter];
84 label.text = labelText; 86 label.text = labelText;
85 [self addSubview:label]; 87 [self addSubview:label];
86 } 88 }
  89 +
87 }else{ 90 }else{
88 _xLabelWidth = (self.frame.size.width)/[xLabels count]; 91 _xLabelWidth = (self.frame.size.width)/[xLabels count];
89 } 92 }