SciChart 3.1.0.5175 running on iOS 13.6
Please see this short video which demonstrates the issue: https://youtu.be/HjtWZDZeyXM
I have a chart showing a single Spline data series. The data series never drops below zero, yet the chart shows multiple points where the line drops below zero as you zoom in and out. This behavior changes as the zoom level changes.
Is this expected behavior for the spline chart? Is there a way to change the behavior so the chart does not show these sub-zero points?
private func drawChart()
{
createChartSurface()
let series = self.getPositionSeries( name: name, color: color, results: resultsSession.rearResults )
self.sciChartSurface?.renderableSeries.add(series)
}
private func createChartSurface()
{
// If we created a chart surface previously then we need to remove it from the superview
sciChartSurface?.removeFromSuperview()
// Create a SCIChartSurface. This is a UIView so can be added directly to the UI
sciChartSurface = SCIChartSurface()
sciChartSurface?.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(sciChartSurface!)
//sciChartSurface?.autoresizingMask = [.flexibleHeight, .flexibleWidth] // chart bottom falls off the view without this
sciChartSurface?.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor).isActive = true
sciChartSurface?.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor).isActive = true
sciChartSurface?.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
sciChartSurface?.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true
// Create an XAxis and YAxis. This step is mandatory before creating series
let xaxis = SCINumericAxis()
xaxis.axisTitle = "Seconds"
sciChartSurface?.xAxes.add(xaxis)
let yaxis = SCINumericAxis()
yaxis.axisTitle = "Position (mm)"
yaxis.axisId = "p" // position
yaxis.axisAlignment = .right
sciChartSurface?.yAxes.add(yaxis)
let yaxis = SCINumericAxis()
yaxis.axisTitle = "Speed mm/s"
yaxis.axisId = "s" // speed
yaxis.axisAlignment = .left
sciChartSurface?.yAxes.add(yaxis)
addModifiers()
}
private func getPositionSeries( name: String, color: UIColor, results: ResultData ) -> SCISplineLineRenderableSeries
{
let positionData = SCIXyDataSeries(xType: .double, yType: .double)
positionData.seriesName = name
let start = resultsSession.indexStart + 1
let last = resultsSession.indexEnd
for index in start ... last {
let t1 = resultsSession.sensorData[index-1].time
let t2 = resultsSession.sensorData[index].time
if ((t2-t1) == 1) {
let x = Double(t2) / resultsSession.sampleRate
let y = results.axleData[index].position
positionData.append(x: x, y: y)
} else {
// There was a gap in the data. Fill in the gap with a horizontal line.
let y = results.axleData[index-1].position
for tx in (t1 + 1) ... t2 {
let x = Double(tx) / resultsSession.sampleRate
positionData.append(x:x, y:y)
}
}
}
let positionSeries = SCISplineLineRenderableSeries() // SCIFastLineRenderableSeries()
positionSeries.dataSeries = positionData
positionSeries.yAxisId = "p"
positionSeries.strokeStyle = SCISolidPenStyle(color: color, thickness: 1.0)
return positionSeries
}
- Michael Chartier asked 4 years ago
- You must login to post comments
Here is a screen shot showing the issue with data points falling below zero.
- Michael Chartier answered 4 years ago
- You must login to post comments
Please login first to submit.