-
-
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
Cubic Line goes too much over the top or below bottom. Needs flattening. #407
Comments
have you set any customAxisMax/Min? It seems it is being clipped? |
No set any
|
It looks like a dashed line... |
The dataSet is quite small: BTW, #330 is also talking about missing data points, though it is for drawLinear. Will it be same issue? |
@zxy198717 any new info? |
@danielgindi @liuxuan30 I created one test project(https://github.com/zxy198717/iOS-Chart-Test), maybe it can help you find the root cause. |
OK But I guess no one is spare to look into it right now.. Mark as bug |
I have the same problem here. Here's the same graph with cubic lines disabled and enabled: At first I thought this was just a matter of changing the padding of the chart or something like that, it's like the cubic rendering makes some bits of the line dip below the visible part of the graph, but I couldn't find anything that helped me solve this, and then I ran into this post. |
Why not set a custom y minimum for the chart, to avoid the clipping?
|
That was fast, thanks. I'm new at this, I'll try to figure out how to do that then… but to avoid a lot of white space below the graph depending on the users' data I'll have to find the minimum value in their data set and always set that custom Y minimum a little bellow that, right? It'll do for now if I can get it to work, but it's not very elegant. |
Well that's because it's a Cubic Bezier line, not a straight line. That's Maybe someone with more expertise in charts with bezier lines could offer On Wed, Nov 18, 2015 at 8:24 AM, danielbmarques [email protected]
|
I also tried this library and the bezier lines look great, so it's certainly possible: I'd rather use your library for the features, though. :( |
We'll look into it @PhilJay ? |
Thanks a lot! |
Well this looks like zero values are simply rendered as normal lines? |
Yes, like when the values reach the real minimum value (not custom min value) - we need to trim them to straight lines. |
I think that's probably the case, duplicating points. |
Anyone solve this issue? My chart is dipping below zero too, and it's so ugly. @danielbmarques did you end up using a better library? |
We will solve it soon. We are working hard on other things. On Tue, Nov 24, 2015 at 1:34 PM, Hannah Carney [email protected]
|
@HannahCarney If all you're interested in is the line itself, I think the best option is this, but you won't even get labels for the axes, you have to set them up yourself. For now I just resorted to doing this: |
@danielgindi Apparently duplicating points isn't the best way to do this after all. I think the way to go is to use UIBezierPath and control points instead of CGPathCreateMutable. It seems pretty straightforward, but I won't have the time to figure out how to add it to the rest of the code for now. You can check this out if you don't mind cheating. |
@danielbmarques IMHO UIBezierPath is not relevant, it works almost exactly like the CGPathCreateMutable. The problem is that there is no (at least i don't know any) spline interpolation method which takes into consideration the relevant constraints. I haven't studied the JBChartView approach, but the BEMSimpleLineGraph library mitigates the error by not using any interpolation, it simply draws bezier curves between points. It works for very simple data, but in most cases it creates ugly "bumpy" plots. Can anyone confirm that JBChartView doesn't have the same problem? I will test in my free time, but AFAIK it should have exactly the same issues. |
@mslazynski Whether it's using Apple's iTunes Connect app has charts that don't have this problem, I wonder how they do it: |
@danielbmarques BEMSimpleLineGraph uses separate segments. JBChartView use some kind of interpolation for sure (it's enough to look at the code you've linked to), however I didn't have time to test whether their interpolation method mitigates the problem. If it is confirmed that JBCharView solved the problem, porting their code should be a 1h piece of work :) I'm sure that there exists the proper way of choosing control points -> I've tried some naive methods, however the resulting plot was always ugly :( |
@mslazynski A while ago, when I first mentioned JBChartView, I tried it with my code and it did fix the problem. I didn't test it really extensively, though; my charts are relatively simple. |
Okay so I went through the code of the other libaries - and it seems like they do a lot of weird and unnecessary calculations. I've managed to deduce the core algorithm for control points, and create a CodePen: The code contains both quad and cubic bezier methods, as I had to simplify and then build to cubic control points. @PhilJay what do you think? |
Looks good. How about performance? Does this new way of drawing e.g. cubic improve performance as well? (it kind of looks like it does) I don't think its too bad if you cannot control intensity anymore, but if we still want that feature, an enum or flag could be sufficient. |
From my tests- it does. If I use the final cubic method- then I'm making the same amount of AddCurveTo calls but with less mathmatics. I think that the cubicIntensity is a nice property to have, and some people might actually want to draw a real cubic, not a trimmed one :) |
@danielgindi Awesome, thank you! |
Awesome, thanks a lot! |
Like the picture, broken sometimes, anyone can help?
set1 = [[LineChartDataSet alloc] initWithYVals:yVals label:@"DataSet 1"];
set1.drawCubicEnabled = YES;
set1.cubicIntensity = 0.5;
When I set
drawCubicEnabled
isNO
, The chart seems ok.The text was updated successfully, but these errors were encountered: