Skip to content

Commit

Permalink
Restored correct velocity sampler
Browse files Browse the repository at this point in the history
  • Loading branch information
rcblue committed Jan 23, 2020
1 parent 0d9b54d commit 5acd48c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions Source/Charts/Charts/PieRadarChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -677,13 +677,25 @@ open class PieRadarChartViewBase: ChartViewBase
}()

// Remove samples older than our sample time - 1 seconds
// while keeping at least one samples
let index = velocitySamples
.dropLast()
.lastIndex { $0.time < currentSample.time - 1 }
if let index = index {
velocitySamples.remove(at: index)
// while keeping at least one sample

var i = 0, count = velocitySamples.count
while (i < count - 2)
{
if currentSample.time - velocitySamples[i].time > 1.0
{
velocitySamples.remove(at: 0)
i -= 1
count -= 1
}
else
{
break
}

i += 1
}

velocitySamples.append(currentSample)
}

Expand Down

0 comments on commit 5acd48c

Please sign in to comment.