ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Highlighting no longer works

russell-garmin opened this issue · comments

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

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)

+1

Thanks!
It's work for me.