kevinzhow

Fix #210

... ... @@ -76,27 +76,33 @@
if (_showLabel) {
[self __addYCoordinateLabelsValues];
} else {
[self processYMaxValue];
}
}
- (void)processYMaxValue {
NSArray *yAxisValues = _yLabels ? _yLabels : _yValues;
_yLabelSum = _yLabels ? _yLabels.count - 1 :_yLabelSum;
if (_yMaxValue) {
_yValueMax = _yMaxValue;
} else {
[self getYValueMax:yAxisValues];
}
if (_yLabelSum==4) {
_yLabelSum = yAxisValues.count;
(_yLabelSum % 2 == 0) ? _yLabelSum : _yLabelSum++;
}
}
#pragma mark - Private Method
#pragma mark - 添加柱状图的Y轴坐标
- (void)__addYCoordinateLabelsValues{
[self viewCleanupForCollection:_yChartLabels];
NSArray *yAxisValues = _yLabels ? _yLabels : _yValues;
_yLabelSum = _yLabels ? _yLabels.count - 1 :_yLabelSum;
if (_yMaxValue) {
_yValueMax = _yMaxValue;
} else {
[self getYValueMax:yAxisValues];
}
if (_yLabelSum==4) {
_yLabelSum = yAxisValues.count;
(_yLabelSum % 2 == 0) ? _yLabelSum : _yLabelSum++;
}
[self processYMaxValue];
float sectionHeight = (self.frame.size.height - _chartMargin * 2 - kXLabelHeight) / _yLabelSum;
for (int i = 0; i <= _yLabelSum; i++) {
... ...
... ... @@ -94,6 +94,7 @@
self.titleLabel.text = @"Bar Chart";
self.barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)];
self.barChart.showLabel = NO;
self.barChart.backgroundColor = [UIColor clearColor];
self.barChart.yLabelFormatter = ^(CGFloat yValue){
CGFloat yValueParsed = yValue;
... ... @@ -108,6 +109,7 @@
[self.barChart setStrokeColors:@[PNGreen,PNGreen,PNRed,PNGreen,PNGreen,PNGreen,PNRed,PNGreen]];
self.barChart.isGradientShow = NO;
self.barChart.isShowNumbers = NO;
[self.barChart strokeChart];
self.barChart.delegate = self;
... ...