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

y axis spaces between labels are too wide #120

Closed
dorsoft opened this issue May 31, 2015 · 3 comments
Closed

y axis spaces between labels are too wide #120

dorsoft opened this issue May 31, 2015 · 3 comments

Comments

@dorsoft
Copy link

dorsoft commented May 31, 2015

The y axis spaces between labels are too wide even when spaceBetweenLabels=0.
I've fixed this issue by changing ChartXAxisRenderer - computeAxis (line 33) from:

var max = Int(round(xValAverageLength + Float(_xAxis.spaceBetweenLabels)));
to
var max = Int(round((xValAverageLength / 2) + Float(_xAxis.spaceBetweenLabels)));

I'm not sure if this is the best way to resolve the issue, it might be better to change ChartData - calcXValAverageLength (line 113):
sum += _xVals[i] == nil ? 0 : _xVals[i]!.lengthOfBytesUsingEncoding(NSUTF16StringEncoding);

@danielgindi
Copy link
Collaborator

Can you show an example? I can't think of a case where the spacing between labels is to wide, as it could absolutely be zero. Maybe you are talking about the modulus of which labels to show. You can set a custom modulus to 0.

@dorsoft
Copy link
Author

dorsoft commented Jun 2, 2015

To see this issue you can use the candle chart sample:

  1. Set the x labels to something like "yyyy MMM dd HH:mm"
  2. Set xAxis.spaceBetweenLabels = 0, xAxis.axisLabelModulus = 0

And you will get something like the screen shot
ios simulator screen shot jun 2 2015 11 55 02 am

@dorsoft
Copy link
Author

dorsoft commented Jun 2, 2015

The thing is that ChartData.calcXValAverageLength returns the average x label length in bytes (not chars) and ChartXAxisRenderer.computeAxis uses the retuned value as chars count.

danielgindi added a commit that referenced this issue Jun 2, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
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

2 participants