1

Is it possible to automatically smooth data for a line chart, so that it displays as a nice graceful curve rather than jagged up-down lines? Or do I need to manually manipulate my data?

Edit: added an example of jagged-line chart

sciChartSurface = SCIChartSurface()
view.addSubview(sciChartSurface)
sciChartSurface.translatesAutoresizingMaskIntoConstraints = false
sciChartSurface.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
sciChartSurface.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
sciChartSurface.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
sciChartSurface.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true

let xAxis = SCIDateTimeAxis()
xAxis.visibleRange = SCIDateRange(dateMin: Date().addingTimeInterval(-86400), max: Date().addingTimeInterval(2 * 86400))
xAxis.growBy = SCIDoubleRange(min: SCIGeneric(0.1), max: SCIGeneric(0.1))
xAxis.textFormatting = "MMM d"
sciChartSurface?.xAxes.add(xAxis)

let yAxis = SCINumericAxis()
yAxis.textFormatting = "%.1f"
yAxis.axisTitle = "Temperature"
sciChartSurface?.yAxes.add(yAxis)

lineDataSeries = SCIXyDataSeries(xType: .dateTime, yType: .double)
lineDataSeries.appendX(SCIGeneric(Date().addingTimeInterval(-86400)), y: SCIGeneric(28))
lineDataSeries.appendX(SCIGeneric(Date()), y: SCIGeneric(30))
lineDataSeries.appendX(SCIGeneric(Date().addingTimeInterval(86400)), y: SCIGeneric(26))
lineDataSeries.appendX(SCIGeneric(Date().addingTimeInterval(2 * 86400)), y: SCIGeneric(28))

let series = SCIFastLineRenderableSeries()
series.dataSeries = lineDataSeries
series.strokeStyle = SCISolidPenStyle(colorCode: 0xFF279B27, withThickness: 1.0)
sciChartSurface.renderableSeries.add(series)

enter image description here

Ben Williams
  • 4,695
  • 9
  • 47
  • 72

1 Answers1

1

SciChart supports a type of Spline interpolation via a custom series. You can see an example here:

iOS Custom Series Spline Line Example

This requires creating a custom series (full source code is provided in the example above, and also hosted on GitHub here.)

Edit: update

Scichart iOS/Android now supports spline line out of the box

https://www.scichart.com/example/ios-spline-line-chart/

Dr. Andrew Burnett-Thompson
  • 20,980
  • 8
  • 88
  • 178
  • 1
    Thanks for the response - I'll take a look into it further! – Ben Williams May 09 '18 at 06:57
  • Does v3.0 that was just recently released support this out of the box? – MobileMon Feb 05 '20 at 19:58
  • Not yet but it is on our work queue. Take a look at https://scichart.com/feedback-policy - we have a feature request for line smoothing. Please vote for it to push it higher in priority! – Dr. Andrew Burnett-Thompson Feb 06 '20 at 20:03
  • @Dr.ABT Thanks for bringing Spline chart, It's working perfectly when I have around 500 data. But when I am trying to plot around 1500 data Spline chart started showing square edges instead of a curve (smooth line). Please help. Thanks in advance. – Tejas Ardeshna Jul 10 '20 at 11:57
  • SciChart now supports spline line out of the box. https://www.scichart.com/example/ios-spline-line-chart/ If you have issues I suggest opening a support ticket with tech support to resolve – Dr. Andrew Burnett-Thompson Jul 11 '20 at 20:01