SciChart iOS v2.x API > 2D Chart Types > The Mountain (Area) Series Type
The Mountain (Area) Series Type

Mountain Series are provided by the SCIFastMountainRenderableSeries type. This draws a polygon between the X-Y line and the ZeroLineY, property on SCIRenderableSeriesProtocol which is a constant Y-value (defaults to zero).

Examples for the Mountain Series can be found in the SciChart iOS Examples Suite

 

To declare a SCIFastMountainRenderableSeriesuse the following code:

 

Declare a SCIFastMountainRenderableSeries

// Create a SCIChartSurface instance
SCIChartSurface * _sciChartSurface = [[SCIChartSurface alloc]initWithFrame:frame];
// NOTE: You will need to add the SCIChartSurface as a SubView to your View
//
// Declare a new XyDataSeries with XType Float, and YType Float
SCIXyDataSeries * dataSeries = [[SCIXyDataSeries alloc] initWithXType:SCIDataType_Float YType:SCIDataType_Float];
// Append some data. SCIGenericStruct converts without boxing of primitives
int dataCount = 20;
for(int i=0; i < dataCount; i++) {
    double time = 10 * i / (double)dataCount;
    double x = time;
    double y = arc4random_uniform(20);
    [dataSeries appendX:SCIGeneric(x) Y:SCIGeneric(y)];
}
// Create a SCIFastMountainRenderableSeries and apply DataSeries
SCIFastMountainRenderableSeries * mountainRenderableSeries = [[SCIFastMountainRenderableSeries alloc] init];
mountainRenderableSeries.areaStyle = [[SCISolidBrushStyle alloc] initWithColorCode:0x77FF6600];
mountainRenderableSeries.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xFFFF6600 withThickness:1.0];
mountainRenderableSeries.dataSeries = dataSeries;
// Note Surface must have an XAxis/YAxis of type SCINumericAxis to match the float,float data
id<SCIAxis2DProtocol> axis = [[SCINumericAxis alloc] init];
[axis setGrowBy: [[SCIDoubleRange alloc]initWithMin:SCIGeneric(0.1) Max:SCIGeneric(0.1)]];
[_sciChartSurface.yAxes add:axis];
axis = [[SCINumericAxis alloc] init];
[axis setGrowBy: [[SCIDoubleRange alloc]initWithMin:SCIGeneric(0.1) Max:SCIGeneric(0.1)]];
[_sciChartSurface.xAxes add:axis];
// Add the Line Series to an existing SciChartSurface
[_sciChartSurface.renderableSeries add:mountainRenderableSeries];
var sciChartSurface = SCIChartSurface(frame: frame)
// NOTE: You will need to add the SCIChartSurface as a SubView to your View
//
// Declare a new XyDataSeries with XType Float, and YType Float
let dataSeries = SCIXyDataSeries(xType: .float, yType: .float)
// Append some data. SCIGenericStruct converts without boxing of primitives
let dataCount: Int = 20
for i in 0..<dataCount {
    let time = (10.0 * Double(i)) / Double(dataCount)
    let x: Double = time;
    let y: Double = Double(arc4random_uniform(20))
    dataSeries.appendX(SCIGeneric(x), y: SCIGeneric(y))
}
// Create a SCIFastMountainRenderableSeries and apply DataSeries
var mountainRenderableSeries = SCIFastMountainRenderableSeries()
mountainRenderableSeries.areaStyle = SCISolidBrushStyle(colorCode: 0x77ff6600)
mountainRenderableSeries.strokeStyle = SCISolidPenStyle(colorCode: 0xffff6600, withThickness: 1.0)
mountainRenderableSeries.dataSeries = dataSeries

// Note Surface must have an XAxis/YAxis of type SCINumericAxis to match the float,float data
let xAxis = SCINumericAxis()
xAxis.growBy = SCIDoubleRange(min: SCIGeneric(0.1), max: SCIGeneric(0.1))
sciChartSurface.yAxes.add(xAxis)
let yAxis = SCINumericAxis()
yAxis.growBy = SCIDoubleRange(min: SCIGeneric(0.1), max: SCIGeneric(0.1))
sciChartSurface.xAxes.add(yAxis)
// Add the Line Series to an existing SciChartSurface
sciChartSurface.renderableSeries.add(mountainRenderableSeries)
var sciChartSurface = new SCIChartSurface();
// NOTE: You will need to add the SCIChartSurface as a SubView to your View
//
// Declare a new XyDataSeries with XType Float, and YType Float
var dataSeries = new XyDataSeries<float, float>();
// Append some data.
int dataCount = 20;
var random = new Random();
for (int i = 0; i < dataCount; i++)
{
    float x = 10 * i / (float)dataCount;
    float y = random.Next(0, 20);
    dataSeries.Append(x, y);
}
// Create a SCIFastMountainRenderableSeries and apply DataSeries
var mountainRenderableSeries = new SCIFastMountainRenderableSeries();
mountainRenderableSeries.AreaStyle = new SCISolidBrushStyle(colorCode: 0x77ff6600);
mountainRenderableSeries.StrokeStyle = new SCISolidPenStyle(colorCode: 0xffff6600, thickness: 1.0f);
mountainRenderableSeries.DataSeries = dataSeries;

// Note Surface must have an XAxis/YAxis of type SCINumericAxis to match the float,float data
var xAxis = new SCINumericAxis { GrowBy = new SCIDoubleRange(0.1, 0.1) };
sciChartSurface.XAxes.Add(xAxis);
var yAxis = new SCINumericAxis { GrowBy = new SCIDoubleRange(0.1, 0.1) };
sciChartSurface.YAxes.Add(yAxis);
// Add the Line Series to an existing SciChartSurface           
sciChartSurface.RenderableSeries.Add(mountainRenderableSeries);

 

Still stuck?

You can check the Online iOS Mountain Chart Example about using this kind of renderable series.

Also our series of Swift and Xamarin Tutorials here.