Skip to content

Commit

Permalink
Restored correct velocity sampler
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi authored and SwiftPolar committed Mar 20, 2023
1 parent 10c245f commit 74bd3f3
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 74bd3f3

Please sign in to comment.