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

line chart: data points do not line up with x-axis tick marks #270

Open
dam13n opened this issue Feb 18, 2016 · 3 comments
Open

line chart: data points do not line up with x-axis tick marks #270

dam13n opened this issue Feb 18, 2016 · 3 comments

Comments

@dam13n
Copy link

dam13n commented Feb 18, 2016

everything seems to be offset backwards by 1 tick

simulator screen shot feb 17 2016 6 08 21 pm

@dam13n
Copy link
Author

dam13n commented Feb 18, 2016

By changing the chart margin, I was able to fix this, but I'm not sure it'll cleanly work across different iPhones.

@dam13n
Copy link
Author

dam13n commented Feb 18, 2016

Think I spoke too soon, haha. Just reduced the plot to two points. Way off. Looks like this now:
simulator screen shot feb 18 2016 1 42 29 pm

@dam13n
Copy link
Author

dam13n commented Feb 18, 2016

Here's the issue I think. In the function - (void)setXLabels:(NSArray *)xLabels withWidth:(CGFloat)width, there is this code:

            NSInteger x = (index *  _xLabelWidth + _chartMarginLeft + _xLabelWidth /2.0 );
            NSInteger y = _chartMarginBottom + _chartCavanHeight;

            PNChartLabel *label = [[PNChartLabel alloc] initWithFrame:CGRectMake(x, y, (NSInteger)_xLabelWidth, (NSInteger)_chartMarginBottom)];
            [label setTextAlignment:NSTextAlignmentCenter];

Because the text alignment is set to center, there is no need to add the _xLabelWidth /2.0 to the x position (as that would be code that does centering itself).

Found another issue too. Gonna make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant