Skip to content

Instantly share code, notes, and snippets.

@jscalo
Last active December 18, 2020 20:45
Show Gist options
  • Save jscalo/4f6c4ba40672abcedbb5316a42218c88 to your computer and use it in GitHub Desktop.
Save jscalo/4f6c4ba40672abcedbb5316a42218c88 to your computer and use it in GitHub Desktop.
private var firstSampleToPlotIdx: Int {
get {
let idx = Int(-viewPort.xTrans * viewPort.screenScale)
return (0..<dataProvider.summarySampleCnt).clamp(idx)
}
}
private var samplesToPlotInVisibleCnt: Int {
get {
return viewPort.visibleXAxisUnits
}
}
private func updatePlot() {
guard let samples = dataProvider.summarySamples else {
return
}
let endIdx = (0..<samples.count).clamp(firstSampleToPlotIdx+samplesToPlotInVisibleCnt)
let samplesToPlot = Array(samples[firstSampleToPlotIdx..<endIdx])
layers.forEach() {
$0.isHidden = true
}
updateLines(samples: samplesToPlot, yMidline: bounds.height / 2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment