Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineChart: fix label and tick mark spacing #271

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions PNChart/PNLineChart.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down Expand Up @@ -708,15 +708,15 @@ - (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);
}

// 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);
Expand Down