-
-
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
entriesForXValue() not finding point with matching xValue when it should #4668
Comments
I have same issue, so as workaround i rewrite method entriesForXValue, using code from older lib version: override func entriesForXValue(_ xValue: Double) -> [ChartDataEntry] This work, but we have some other issues, i m not think they are related to this, like rendering only first from multiple graphs.. I think this issue also have same problem : #4645 Markers not appearing as expected |
It work,thanks |
I can confirm that 3.6.0 fixes the selection issue. 4.0.1 version is busted. |
…ng xValue when it should" (ChartsOrg#4668). Resolves Issue 4645 "Markers not appearing as expected" (ChartsOrg#4645). The entriesForXValue function was incorrectly partiioning on ==, and also sometimes incorrectly returning an array of values that don't match at all. The entryIndex function's switch statement assumes that the closest X value had already been found, which would often not be the case, since we are partitioning on >=.
Have a fix open for this #4817 |
Closed by #4721 |
What did you do?
Tapped a point on my LineChart
What did you expect to happen?
Highlight a point
What happened instead?
Failed to highlight point
Charts Environment
Charts version/Branch/Commit Number:master
Xcode version:Latest
Swift version:Latest
Platform(s) running Charts:iPhoneX
macOS version running Xcode:BigSur
Demo Project
Unable to produce
Reason for this to happen
In entriesForXValue(_ xValue: Double) -> [ChartDataEntry] of ChartDataSet
it uses partitioningIndex() to find the first index that matches the xValue.
The xValue is from:
closest = set.entryForXValue(xValue, closestToY: .nan, rounding: rounding)
Which I have verified is working properly:

As you can see xValue matches the x value of the entry at index 3. using firstIndex() also produces index 3, but partitioningIndex() returns the the index after the last of entries.
So to debug this, after the case where it could not find the index I manually check every entry and Int round them, If I find a match I then test firstIndex() using the same predicate as partitioningIndex() (so no Int rounding), and this works.
partitioningIndex() does work sometimes but I couldn't figure out a common cause.
Assuming my assumption that partitioningIndex() and firstIndex() should do the same thing then partitioningIndex() is broken.
Any ideas how to properly fix this? for the meantime I may just use firstIndex() on my fork.
The text was updated successfully, but these errors were encountered: