Skip to content
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

Highlighting no longer works #4814

Closed
russell-garmin opened this issue Apr 20, 2022 · 4 comments
Closed

Highlighting no longer works #4814

russell-garmin opened this issue Apr 20, 2022 · 4 comments

Comments

@russell-garmin
Copy link

Tested change from 4.0.0 to 4.0.2.

partitioningIndex appears to be used incorrectly. $0.x == xValue should be a different closure that runs $0.x >= xValue. Existing match closure should be used for .prefix(while:) only.

The fix:

open override func entriesForXValue(_ xValue: Double) -> [ChartDataEntry]
{
    let belongsInSecondPartition: (ChartDataEntry) -> Bool = { $0.x >= xValue }
    let i = partitioningIndex(where: belongsInSecondPartition)
    guard i < endIndex else { return [] }

    let match: (ChartDataEntry) -> Bool = { $0.x == xValue }
    return self[i...].prefix(while: match)
}

https://github.com/danielgindi/Charts/blob/b61fc9b97829ab9b954d01f96e601d52045ef5dc/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift#L200

@dudenamedjune
Copy link

Think I have a proper fix open for this #4817 which is basically the same as yours with a few extra lines to handle closest values in a more elegant way
#4719 (comment)

@PorterHoskins
Copy link

+1

@IvanTulaev
Copy link

Thanks!
It's work for me.

@pmairoldi
Copy link
Collaborator

Closed by #4721

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants