diff --git a/PNChart/PNLineChart.m b/PNChart/PNLineChart.m index ec40cc8c..f1731c95 100755 --- a/PNChart/PNLineChart.m +++ b/PNChart/PNLineChart.m @@ -202,7 +202,7 @@ - (void)setXLabels:(NSArray *)xLabels withWidth:(CGFloat)width for (int index = 0; index < xLabels.count; index++) { labelText = xLabels[index]; - NSInteger x = (index * _xLabelWidth + _chartMarginLeft + _xLabelWidth /2.0 ); + NSInteger x = (index * _xLabelWidth + _chartMarginLeft ); NSInteger y = _chartMarginBottom + _chartCavanHeight; PNChartLabel *label = [[PNChartLabel alloc] initWithFrame:CGRectMake(x, y, (NSInteger)_xLabelWidth, (NSInteger)_chartMarginBottom)]; @@ -708,7 +708,7 @@ - (void)drawRect:(CGRect)rect // draw x axis separator CGPoint point; for (NSUInteger i = 0; i < [self.xLabels count]; i++) { - point = CGPointMake(2 * _chartMarginLeft + (i * _xLabelWidth), _chartMarginBottom + _chartCavanHeight); + point = CGPointMake(_chartMarginLeft + ( i * _xLabelWidth ) + _xLabelWidth / 2, _chartMarginBottom + _chartCavanHeight); CGContextMoveToPoint(ctx, point.x, point.y - 2); CGContextAddLineToPoint(ctx, point.x, point.y); CGContextStrokePath(ctx); @@ -716,7 +716,7 @@ - (void)drawRect:(CGRect)rect // draw y axis separator CGFloat yStepHeight = _chartCavanHeight / _yLabelNum; - for (NSUInteger i = 0; i < [self.xLabels count]; i++) { + for (NSUInteger i = 0; i < self.yLabelNum; i++) { point = CGPointMake(_chartMarginBottom + yAxisOffset, (_chartCavanHeight - i * yStepHeight + _yLabelHeight / 2)); CGContextMoveToPoint(ctx, point.x, point.y); CGContextAddLineToPoint(ctx, point.x + 2, point.y);