             break
         }
 
-        guard closest < endIndex else { return endIndex }
-            
         // Search by closest to y-value
         if !yValue.isNaN
         {

        rounding: ChartDataSetRounding) -> Int
    {
        var closest = partitioningIndex { $0.x >= xValue }
        guard closest < endIndex else { return closest }

        let closestXValue = self[closest].x


            var closestYValue = self[closest].y
            var closestYIndex = closest

            while closest < index(before: endIndex)
            {
                formIndex(after: &closest)
                let value = self[closest]
