-
-
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
Fix chart only drawing first entry #4829
Conversation
I've tested our apps' graphs with the results from this PR and I can confirm this solves our problem. Good job! I'll pull the updated version in our app as soon as it get available in a release. |
It would be highly appreciated if this fix can make it to the next release. |
Any thoughts on when this fix might be merged? |
Maybe @pmairoldi can tell us when we can expect this fix to be merged? |
Any word on when this can move forward @pmairoldi ? We ran into this same issue and can confirm this change fixes it. |
Hi @FelixHerrmann this totally solves my problem. In my case I had a lineChart combined with two other lineCharts configured to not show the lines, but just relevant points (mins a maxs detected with my algorithm) So yes that would be great to have this merged with master. Thanks! |
Awesome @cbalsalobre, thanks for confirming! |
We are waiting for merging this for a long time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix should be in before anything else.
@fumoboy007 I think if you edit your comment to 'approve' the 'open discussion' will be closed and this PR will be pulled in. |
Thanks for the contribution. Will be out with the next version for Xcode 14 |
Hello @pmairoldi Do you know when the next release of this lib will be available? Thanks |
Issue Link π
#4819 #4792 #4753 #4739 #4722 #4699 (and possibly a lot more)
Goals β½
Fixing line chart only drawing first entry when spaceMax on xAxis is not 0.
This will fix the candle stick chart only drawing first value as well!
Implementation Details π§
With the addition of the swift-algorithms package in v4.0.0 many search algorithms have changed, including the one in ChartDataSet.entryIndex(x:closestToY:rounding:).
It turns out that partitioningIndex works different in one situation: when the given value is greater than the greatest value in the array.
Because of that, we need some kind of check that ensures we don't get an index out of bounds.
#4577 #4721 and the initial implementation #4497 do those checks, but wrong. The initial implementation is the best, the index is just one too high as shown in the screenshot above. We simply need to return the last possible index if a higher value is requested. Returning -1 in this situation will result in only drawing the first value!
In addition to that, I replaced all the raw index manipulation with the standard lib APIs and fixed Package.resolved to reflect the versions from the Package.swift!
Testing Details π
I tested in the demo projects and my personal one.