iOS & macOS Charting Documentation - SciChart iOS & macOS Charts SDK v4.x

The Line Series Type

Line Series can be created using the SCIFastLineRenderableSeries type.

Line Series Type

NOTE: Examples of the Line Series can be found in the SciChart iOS Examples Suite as well as on GitHub:

Digital (Step) Line Series

SCIFastLineRenderableSeries can be configured to draw as Digital (Step) Line. It is achieved via the SCIFastLineRenderableSeries.isDigitalLine property.

Digital Line Series Type

Create a Line Series

To create a SCIFastLineRenderableSeries, use the following code:

// Assume a surface has been created and configured somewhere id<ISCIChartSurface> surface; // Create DataSeries and fill it with some data SCIXyDataSeries *dataSeries = [[SCIXyDataSeries alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double]; // Create and add Line Series id<ISCIRenderableSeries> lineSeries = [SCIFastLineRenderableSeries new]; lineSeries.dataSeries = dataSeries; lineSeries.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xFF279B27 thickness:2.0]; [surface.renderableSeries add:lineSeries];
// Assume a surface has been created and configured somewhere let surface: ISCIChartSurface // Create DataSeries and fill it with some data let dataSeries = SCIXyDataSeries(xType: .double, yType: .double) // Create and add Line Series let lineSeries = SCIFastLineRenderableSeries() lineSeries.dataSeries = dataSeries lineSeries.strokeStyle = SCISolidPenStyle(colorCode: 0xFF279B27, thickness: 2.0) surface.renderableSeries.add(lineSeries)
// Assume a surface has been created and configured somewhere IISCIChartSurface surface; // Create DataSeries and fill it with some data var dataSeries = new XyDataSeries(); // Create and add Line Series var lineSeries = new SCIFastLineRenderableSeries(); lineSeries.DataSeries = dataSeries; lineSeries.StrokeStyle = new SCISolidPenStyle(0xFF279B27, 2.0f); surface.RenderableSeries.Add(lineSeries);

In the code above, a Line Series instance is created. It is assigned to draw the data that is provided by the ISCIDataSeries assigned to it. The line is drawn with a Pen provided by the SCIPenStyle instance. Finally, the Line Series is added to the ISCIChartSurface.renderableSeries property.

Line Series Features

Line Series also has some features similar to other series, such as:

Render a Gap in a Line Series

It is possible to show a gap in a Line Series by passing a data point with a NaN as the Y value. Please refer to the RenderableSeries APIs article for more details. The SCIFastLineRenderableSeries, however, allows to specify how a gap should appear. You can treat NAN values as gaps or close the line. That’s defined by the SCIRenderableSeriesBase.drawNaNAs property (Please see SCILineDrawMode enumeration).

Add Point Markers onto a Line Series

Every data point of a Line Series can be marked with a ISCIPointMarker. To add Point Markers to the Line Series, use the following code:

Point Markers

// Create a Triangle PointMarker instance id<ISCIPointMarker> pointMarker = [SCITrianglePointMarker new]; pointMarker.size = (CGSize){ .width = 40, .height = 40 }; pointMarker.strokeStyle = [[SCISolidPenStyle alloc] initWithColor:UIColor.greenColor thickness:2.0]; pointMarker.fillStyle = [[SCISolidBrushStyle alloc] initWithColor:UIColor.redColor]; // Apply the PointMarker to a LineSeries id<ISCIRenderableSeries> lineSeries = [SCIFastLineRenderableSeries new]; lineSeries.pointMarker = pointMarker;
// Create a Triangle PointMarker instance let pointMarker = SCITrianglePointMarker() pointMarker.size = CGSize(width: 40, height: 40) pointMarker.strokeStyle = SCISolidPenStyle(color: .green, thickness: 2.0) pointMarker.fillStyle = SCISolidBrushStyle(color: .red) // Apply the PointMarker to a LineSeries let lineSeries = SCIFastLineRenderableSeries() lineSeries.pointMarker = pointMarker
// Create a Triangle PointMarker instance var pointMarker = new SCITrianglePointMarker(); pointMarker.Size = new CGSize(40, 40); pointMarker.StrokeStyle = new SCISolidPenStyle(UIColor.Green, 2.0f); pointMarker.FillStyle = new SCISolidBrushStyle(UIColor.Red); // Apply the PointMarker to a LineSeries var lineSeries = new SCIFastLineRenderableSeries(); lineSeries.PointMarker = pointMarker;

To learn more about Point Markers, please refer to the PointMarkers API article.

NOTE: This feature can be used to create a Scatter Series, if ISCIRenderableSeries.strokeStyle contains a transparent Pen.

Paint Line Segments With Different Colors

In SciChart, you can draw line segments with different colors using the PaletteProvider API. To Use palette provider for Line Series - a custom ISCIStrokePaletteProvider has to be provided to the ISCIRenderableSeries.paletteProvider property. For more information - please refer to the PaletteProvider API article.