Showing
1 changed file
with
13 additions
and
11 deletions
| @@ -67,18 +67,20 @@ | @@ -67,18 +67,20 @@ | ||
| 67 | CGFloat yStep = (_yValueMax - _yValueMin) / _yLabelNum; | 67 | CGFloat yStep = (_yValueMax - _yValueMin) / _yLabelNum; |
| 68 | CGFloat yStepHeight = _chartCavanHeight / _yLabelNum; | 68 | CGFloat yStepHeight = _chartCavanHeight / _yLabelNum; |
| 69 | 69 | ||
| 70 | + if (_showLabel) { | ||
| 71 | + | ||
| 72 | + NSInteger index = 0; | ||
| 73 | + NSInteger num = _yLabelNum + 1; | ||
| 70 | 74 | ||
| 71 | - NSInteger index = 0; | 75 | + while (num > 0) { |
| 72 | - NSInteger num = _yLabelNum + 1; | 76 | + PNChartLabel *label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0.0, (_chartCavanHeight - index * yStepHeight), _chartMargin, _yLabelHeight)]; |
| 73 | - | 77 | + [label setTextAlignment:NSTextAlignmentRight]; |
| 74 | - while (num > 0) { | 78 | + NSString *yLabelFormat = self.yLabelFormat ? self.yLabelFormat : @"%1.f"; |
| 75 | - PNChartLabel *label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0.0, (_chartCavanHeight - index * yStepHeight), _chartMargin, _yLabelHeight)]; | 79 | + label.text = [NSString stringWithFormat:yLabelFormat, _yValueMin + (yStep * index)]; |
| 76 | - [label setTextAlignment:NSTextAlignmentRight]; | 80 | + [self addSubview:label]; |
| 77 | - NSString *yLabelFormat = self.yLabelFormat ? self.yLabelFormat : @"%1.f"; | 81 | + index += 1; |
| 78 | - label.text = [NSString stringWithFormat:yLabelFormat, _yValueMin + (yStep * index)]; | 82 | + num -= 1; |
| 79 | - [self addSubview:label]; | 83 | + } |
| 80 | - index += 1; | ||
| 81 | - num -= 1; | ||
| 82 | } | 84 | } |
| 83 | } | 85 | } |
| 84 | 86 |
-
Please register or login to post a comment