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

Straight lines #94

Closed
simonbromberg opened this issue Aug 24, 2014 · 7 comments
Closed

Straight lines #94

simonbromberg opened this issue Aug 24, 2014 · 7 comments
Labels

Comments

@simonbromberg
Copy link

In the screenshot below the points have been given vertical values that incremented by 5 (e.g. 0,5,10...)

As you can see, the last one is slightly askew and so the line is not straight

I printed out the y-offsets and got the following 0,22,45,68,90,112
Some of these are increments of 22 and some are increments of 23.

ios simulator screen shot aug 24 2014 3 50 00 pm

@terryworona
Copy link
Collaborator

@simonbromberg it's likely a rounding "feature" due to the padding that is calculated.

The padding is a function of dot radius & can vary.

To avoid drawing subviews @ half pixels, the ceiling of positions are taken.

It's unlikely that this can be resolved; just something you may have to live with.

@simonbromberg
Copy link
Author

Shouldn't everything just be rounded down?
Doesn't make sense to me to ignore this issue... The points should be equally spaced.

Doesn't look so bad on this vertically condensed graph, but it's a lot more noticeable on other sizes, plus it makes it very difficult to line the chart up with a vertical axis.

@terryworona terryworona reopened this Aug 24, 2014
@terryworona
Copy link
Collaborator

Sorry didn't mean to close it. I'll look into it when I have some time - feel free to do the same.

@stefreak
Copy link

It seems to help to set a minValue that is slightly smaller than the real minValue and a maxValue that is slightly bigger than the actual one.

@terryworona
Copy link
Collaborator

It appears that the line width /2 is subtracted from both the max Y and min Y.

This issue only applies to linear lines that approach the max or min Y values of the chart. It will cause the slope of the line to be modified by a factor of half the line's width.

Example:

{3, 132}
{52, 112.5} -> [49, 19.5]
{101, 90} -> [49, 22.5]
{150, 67.5} -> [49, 22.5]
{199, 45} -> [49, 22.5]
{248, 22.5} -> [49, 22.5]
{297, 3} -> [49, 19.5]

Delta's are in " [ ] ". Notice the top and bottom deltas are 19.5, while the middle deltas are all 22.5.

@terryworona
Copy link
Collaborator

One such solution is to reduce the internal available height by the max line width. This way we can remove the need to account for padding when building our CGPath.

Seems to be working. Screen attached. I still need to run some tests to determine if it's a safe change.

screen shot 2015-11-20 at 5 48 13 pm

@terryworona
Copy link
Collaborator

Fixed via commit: 9828034

Screenshot attached.

Thanks for patience!

screen shot 2015-11-22 at 6 52 34 pm

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

No branches or pull requests

3 participants