SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0 votes

SciChart running on iOS 13.6

Please see this short video which demonstrates the issue:

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()

    let series = self.getPositionSeries( name: name, color: color, results: resultsSession.rearResults )


private func createChartSurface()
    // If we created a chart surface previously then we need to remove it from the superview

    // Create a SCIChartSurface. This is a UIView so can be added directly to the UI
    sciChartSurface = SCIChartSurface()
    sciChartSurface?.translatesAutoresizingMaskIntoConstraints = false

    //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"

    let yaxis = SCINumericAxis()
    yaxis.axisTitle = "Position (mm)"
    yaxis.axisId = "p" // position
    yaxis.axisAlignment = .right

    let yaxis = SCINumericAxis()
    yaxis.axisTitle = "Speed mm/s"
    yaxis.axisId = "s" // speed
    yaxis.axisAlignment = .left


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
1 vote

I found the example for spline drawing, but it’s still missing the gradient brush that mountain series have, how can I add it? thanks

0 votes

In our view model, the data range is expanded to include data outside of the X-Axis range. This is done to preserve the spline curve which is defined by previous points– doing this prevents the spline curve from changing drastically by including X number of points outside the range.

When the Draw function is called, the point context that was bound in is filtered to the X Axis range which leads to the spline curve changing as you pan (especially noticeable if it affects a peak).

How can I change this behavior to preserve the spline line?

Updated — Setting ResampleMode = None does not give me all the points.

Showing 3 results
This template supports the sidebar's widgets. Add one or use Full Width layout.