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

Top and bottom grid line diverging widths #411

Closed
lucaswehmuth opened this issue Sep 23, 2015 · 5 comments
Closed

Top and bottom grid line diverging widths #411

lucaswehmuth opened this issue Sep 23, 2015 · 5 comments

Comments

@lucaswehmuth
Copy link

Hello there,
I'm currently struggling to change the implementation of the function renderGridLines found in ChartYAxisRenderer.swift in order to prevent this from happening:

http://i.imgur.com/yASDJAm.png

As you can see, the top and bottom lines have different widths and I'd like all of them to look exactly the same. I tried fixing this by editing the values of the CGContext but I couldn't find out how :(
Can anyone give me a light on this? Or maybe at least point me a direction on how to solve this problem.

@danielgindi
Copy link
Collaborator

I guess that the line is just clipped because of being drawn from its middle. It's the default behaviour of graphics drawing. I'll see if we can handle that gracefully.

@liuxuan30
Copy link
Member

Quick workaround is move your desired grid lines outside of CGContextClipToRect(context, _viewPortHandler.contentRect), like after CGContextRestoreGState(context). But it may have side effect, since it cannot clipped the additional stuff.

@vvit
Copy link
Contributor

vvit commented Oct 14, 2015

I have the same problem, but my chart grid line is clipped on the bottom:
http://i.imgur.com/51whtKb.png

Indeed, placing _leftYAxisRenderer?.renderGridLines(context: context) before CGContextClipToRect(context, _viewPortHandler.contentRect) (or commenting this line out) helps. But this could only be a temporary solution.

Another solution that worked for me: replace
CGContextClipToRect(context, _viewPortHandler.contentRect)
with
CGContextClipToRect(context, _viewPortHandler.contentRect.insetBy(dx: 0, dy: -1))
in BarLineChartViewBase.swift:189

@danielgindi
Copy link
Collaborator

Well this needs some careful considerations. I thought about adding an offset to the lines, the size of half the line width. But that would lose the center focus of the value on the line.

So we need a partial clipping of the grid lines. Just adjust the clipping rect for the grid, vertically, by half the line width.

I hope to take care of this soon

@odedharth
Copy link

Also have this problem.
Wandering if there was a progress on this or fix that doesn't requires forking the library?

fullsizerender 2

@jjatie jjatie closed this as completed Apr 1, 2018
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

6 participants