-
Notifications
You must be signed in to change notification settings - Fork 11
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
Sparkline graph clipped at top on macOS #13
Comments
Hey @martindufort, Apologies for not responding sooner -- unfortunately the issue is that the algorithm I'm using to smooth the line introduces overshoot into the line and it ends up drawing outside the drawable bounds of the graph. A simple workaround is to turn off interpolation (which is, of course, not a great solution). Without interpolation the overshoot doesn't occur. I've worked out a proper solution but it has a bit of a wide-ranging impact on the line graph itself, which means that it will take more time to implement and test correctly. And unfortunately I've been swamped work-wise as well which hasn't been helping. Hoping I can get up a fix for this soon. |
@martindufort can you tell me how you're displaying the graph? Are you using a |
Hey @dagronf, thanks for the reply.
Let me know if you need more information. |
Just tried without interpolation within our Labs Project, there is no overshoot but the graph looks meh ;) self.view.layer?.masksToBounds = false but the clipping is still occuring. |
Hey @martindufort, The issue arises with the old code when there are two (or more) consecutive values near the upper or lower bounds of the graph. The interpolation overshoot ends up being higher than the upper bounds, which means that it gets clipped. Interestingly enough, I tried the same as you I've made changes to the code to take into account the interpolation overshoot (basically insetting the graph by a percent of the graph height), and I think I haven't introduced any line rendering errors. This means that interpolated line graphs will have a slight inset at the top and bottom. I've pushed the code to a branch called Cheers and thanks! |
I was actually looking at the code trying to figure out same. Thanks for this |
Ok it's working for me...
|
Okay - that's good news! I'll push the changes to master and tag it as 5.0.0. When you next get a chance if you could link against master tag 5.0.0 and let me know if all seems well? Many thanks for the feedback and patience mate. |
Super... validated and working with |
I'm using DSFSparkline within our macOS app to display a last 30-day activity chart. Currently the chart is generated with random numbers like:
That graph is contained within a view and constrained to the bottom with a specific height of 30
However I noticed that, in some cases, the top of the graph is clipped.
See screenshot:
Thanks
The text was updated successfully, but these errors were encountered: