From 51423838287e19b05df2203b529b701eb2e2623f Mon Sep 17 00:00:00 2001 From: Damien Date: Thu, 18 Feb 2016 15:07:42 -0800 Subject: [PATCH 1/2] LineChart: fix label and tick mark spacing --- PNChart/PNLineChart.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PNChart/PNLineChart.m b/PNChart/PNLineChart.m index ec40cc8c..360e8c37 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); From 3ba8d32bd6133c248e5ca6c34173dba42cb3f699 Mon Sep 17 00:00:00 2001 From: Damien Date: Tue, 1 Mar 2016 18:21:36 -0800 Subject: [PATCH 2/2] LineChart: fix ylabel tick count --- PNChart/PNLineChart.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PNChart/PNLineChart.m b/PNChart/PNLineChart.m index 360e8c37..f1731c95 100755 --- a/PNChart/PNLineChart.m +++ b/PNChart/PNLineChart.m @@ -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);