Showing
2 changed files
with
14 additions
and
6 deletions
| @@ -76,15 +76,12 @@ | @@ -76,15 +76,12 @@ | ||
| 76 | 76 | ||
| 77 | if (_showLabel) { | 77 | if (_showLabel) { |
| 78 | [self __addYCoordinateLabelsValues]; | 78 | [self __addYCoordinateLabelsValues]; |
| 79 | + } else { | ||
| 80 | + [self processYMaxValue]; | ||
| 79 | } | 81 | } |
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | -#pragma mark - Private Method | 84 | +- (void)processYMaxValue { |
| 83 | -#pragma mark - 添加柱状图的Y轴坐标 | ||
| 84 | -- (void)__addYCoordinateLabelsValues{ | ||
| 85 | - | ||
| 86 | - [self viewCleanupForCollection:_yChartLabels]; | ||
| 87 | - | ||
| 88 | NSArray *yAxisValues = _yLabels ? _yLabels : _yValues; | 85 | NSArray *yAxisValues = _yLabels ? _yLabels : _yValues; |
| 89 | _yLabelSum = _yLabels ? _yLabels.count - 1 :_yLabelSum; | 86 | _yLabelSum = _yLabels ? _yLabels.count - 1 :_yLabelSum; |
| 90 | if (_yMaxValue) { | 87 | if (_yMaxValue) { |
| @@ -97,6 +94,15 @@ | @@ -97,6 +94,15 @@ | ||
| 97 | _yLabelSum = yAxisValues.count; | 94 | _yLabelSum = yAxisValues.count; |
| 98 | (_yLabelSum % 2 == 0) ? _yLabelSum : _yLabelSum++; | 95 | (_yLabelSum % 2 == 0) ? _yLabelSum : _yLabelSum++; |
| 99 | } | 96 | } |
| 97 | +} | ||
| 98 | + | ||
| 99 | +#pragma mark - Private Method | ||
| 100 | +#pragma mark - 添加柱状图的Y轴坐标 | ||
| 101 | +- (void)__addYCoordinateLabelsValues{ | ||
| 102 | + | ||
| 103 | + [self viewCleanupForCollection:_yChartLabels]; | ||
| 104 | + | ||
| 105 | + [self processYMaxValue]; | ||
| 100 | 106 | ||
| 101 | float sectionHeight = (self.frame.size.height - _chartMargin * 2 - kXLabelHeight) / _yLabelSum; | 107 | float sectionHeight = (self.frame.size.height - _chartMargin * 2 - kXLabelHeight) / _yLabelSum; |
| 102 | for (int i = 0; i <= _yLabelSum; i++) { | 108 | for (int i = 0; i <= _yLabelSum; i++) { |
| @@ -94,6 +94,7 @@ | @@ -94,6 +94,7 @@ | ||
| 94 | self.titleLabel.text = @"Bar Chart"; | 94 | self.titleLabel.text = @"Bar Chart"; |
| 95 | 95 | ||
| 96 | self.barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; | 96 | self.barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; |
| 97 | + self.barChart.showLabel = NO; | ||
| 97 | self.barChart.backgroundColor = [UIColor clearColor]; | 98 | self.barChart.backgroundColor = [UIColor clearColor]; |
| 98 | self.barChart.yLabelFormatter = ^(CGFloat yValue){ | 99 | self.barChart.yLabelFormatter = ^(CGFloat yValue){ |
| 99 | CGFloat yValueParsed = yValue; | 100 | CGFloat yValueParsed = yValue; |
| @@ -108,6 +109,7 @@ | @@ -108,6 +109,7 @@ | ||
| 108 | [self.barChart setStrokeColors:@[PNGreen,PNGreen,PNRed,PNGreen,PNGreen,PNGreen,PNRed,PNGreen]]; | 109 | [self.barChart setStrokeColors:@[PNGreen,PNGreen,PNRed,PNGreen,PNGreen,PNGreen,PNRed,PNGreen]]; |
| 109 | self.barChart.isGradientShow = NO; | 110 | self.barChart.isGradientShow = NO; |
| 110 | self.barChart.isShowNumbers = NO; | 111 | self.barChart.isShowNumbers = NO; |
| 112 | + | ||
| 111 | [self.barChart strokeChart]; | 113 | [self.barChart strokeChart]; |
| 112 | 114 | ||
| 113 | self.barChart.delegate = self; | 115 | self.barChart.delegate = self; |
-
Please register or login to post a comment