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 lines are clipped #2963

Closed
bdorfman opened this issue Nov 6, 2017 · 5 comments
Closed

Line chart lines are clipped #2963

bdorfman opened this issue Nov 6, 2017 · 5 comments

Comments

@bdorfman
Copy link

bdorfman commented Nov 6, 2017

If you, for example, on a LineChartView set leftAxis.axisMinimum to 0, then the line itself will be clipped at 0 instead of being full width. Setting clipValuesToContentEnabled to true doesn't fix this, nor does altering the minOffset of the view. And there is no easy way that I can think of to offset axisMinimum to compensate for lineWidth (since the width is in screen points which will not translate neatly to an axis value).

Example screenshot of this behavior:
simulator006

@liuxuan30
Copy link
Member

that's a little tricky, as you specifically have line segment from 0 to 0, while you set clip on 0 line. That's done by CoreGraphics. One workaround is you modify contentRect.height to include half line width.
clipValuesToContentEnabled is for the value labels clipping, so it will not work in your case for sure.

@wtmoose
Copy link
Contributor

wtmoose commented Mar 20, 2018

One workaround is you modify contentRect.height to include half line width.

I don't see how this is a workaround. The clipping area needs to be larger than the drawing area, but both are defined by the contentRect. So in this case, increasing contentRect draws the path larger and it is still clipped.

It seems that the solution would require having the following line of code apply an additional offset to contentRect:

context.clip(to: _viewPortHandler.contentRect)

Am I missing something?

@bdorfman
Copy link
Author

Yes, the suggested contectRect clipping doesn't work. I believe the solution I came up with was to do a somewhat complicated conversion between screen points/pixels and the graphs coordinate space and then shift the axis miminum and maximums so that they wouldn't clip. It's annoying and you have to recalculate whenever the pixel size of the graph changes. I still think this is a bug and should be handled for you by the library.

@wtmoose
Copy link
Contributor

wtmoose commented Mar 21, 2018

@bdorfman I can see why it works the way it does: clipping is needed for the case where values fall outside of the viewport. If the clipping region were extended, a line that crosses the viewport would get clipped beyond the axes, which might look bad.

But for data sets lie wholly within the viewport, it would be nice to have the option of disabling clipping entirely.

@danielgindi would a PR that adds an option to disable viewport clipping have a chance of being accepted?

@liuxuan30
Copy link
Member

my apology if workaround not work. But the idea is similar, you have to give more space for the lines to avoid clipping.
For PR - Yes we definitely accept any meaningful PR and you are more than welcome.

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

3 participants