Showing
2 changed files
with
4 additions
and
3 deletions
| @@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
| 12 | #define xLabelMargin 15 | 12 | #define xLabelMargin 15 |
| 13 | #define yLabelMargin 15 | 13 | #define yLabelMargin 15 |
| 14 | #define yLabelHeight 11 | 14 | #define yLabelHeight 11 |
| 15 | +#define xLabelHeight 20 | ||
| 15 | 16 | ||
| 16 | @interface PNBarChart : UIView | 17 | @interface PNBarChart : UIView |
| 17 | 18 |
| @@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
| 85 | for(int index = 0; index < _xLabels.count; index++) | 85 | for(int index = 0; index < _xLabels.count; index++) |
| 86 | { | 86 | { |
| 87 | NSString* labelText = _xLabels[index]; | 87 | NSString* labelText = _xLabels[index]; |
| 88 | - PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin), self.frame.size.height - 30.0, _xLabelWidth, 20.0)]; | 88 | + PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin), self.frame.size.height - xLabelHeight - chartMargin, _xLabelWidth, xLabelHeight)]; |
| 89 | [label setTextAlignment:NSTextAlignmentCenter]; | 89 | [label setTextAlignment:NSTextAlignmentCenter]; |
| 90 | label.text = labelText; | 90 | label.text = labelText; |
| 91 | [_labels addObject:label]; | 91 | [_labels addObject:label]; |
| @@ -95,7 +95,7 @@ | @@ -95,7 +95,7 @@ | ||
| 95 | 95 | ||
| 96 | [self viewCleanupForCollection:_bars]; | 96 | [self viewCleanupForCollection:_bars]; |
| 97 | 97 | ||
| 98 | - CGFloat chartCavanHeight = self.frame.size.height - chartMargin * 2 - 40.0; | 98 | + CGFloat chartCavanHeight = self.frame.size.height - chartMargin*2 - xLabelHeight*2; |
| 99 | NSInteger index = 0; | 99 | NSInteger index = 0; |
| 100 | 100 | ||
| 101 | for (NSString * valueString in _yValues) { | 101 | for (NSString * valueString in _yValues) { |
| @@ -104,7 +104,7 @@ | @@ -104,7 +104,7 @@ | ||
| 104 | float grade = (float)value / (float)_yValueMax; | 104 | float grade = (float)value / (float)_yValueMax; |
| 105 | PNBar * bar; | 105 | PNBar * bar; |
| 106 | if (_showLabel) { | 106 | if (_showLabel) { |
| 107 | - bar = [[PNBar alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin + _xLabelWidth * 0.25), self.frame.size.height - chartCavanHeight - 30.0, _xLabelWidth * 0.5, chartCavanHeight)]; | 107 | + bar = [[PNBar alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin + _xLabelWidth * 0.25), self.frame.size.height - chartCavanHeight - xLabelHeight - chartMargin, _xLabelWidth * 0.5, chartCavanHeight)]; |
| 108 | 108 | ||
| 109 | } | 109 | } |
| 110 | else{ | 110 | else{ |
-
Please register or login to post a comment