-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Comments
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 |
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 It seems that the solution would require having the following line of code apply an additional offset to context.clip(to: _viewPortHandler.contentRect) Am I missing something? |
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. |
@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? |
my apology if workaround not work. But the idea is similar, you have to give more space for the lines to avoid clipping. |
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. SettingclipValuesToContentEnabled
to true doesn't fix this, nor does altering theminOffset
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:
The text was updated successfully, but these errors were encountered: