Pre loader

iOS & macOS Spline Band Chart

iOS & macOS charts - Examples

Please note! These examples are new to SciChart iOS v4 release! SciChart’s OpenGL ES and Metal iOS and Metal macOS Chart library ships with hundred of Objective-C and Swift iOS & macOS Chart Examples which you can browse, play with and view the source-code. All of this is possible with the new and improved SciChart iOS Examples Suite and demo application for Mac, which ships as part of the SciChart SDK.

Download Examples

Spline Band Series are provided by the SCISplineBandRenderableSeries type. This accepts data (X, Y, Y1) from a SCIXyyDataSeries and renders two lines with a polygon, which changes color depending on whether Y > Y1 or vice versa.

The iOS Spline Band Examples showcases the smoothing of the lines that can be used, when you have too many data points in your raw data and displaying it as it is makes the chart difficult to read the trends. The smoothing gives the charts in your iOS applications slick look and your customers a good user experience.

Spline Line Series Features:

  • – Render a Gap in iOS Spline Line
  • – Draw Point Markers
  • – Draw Series With Different Colors

Read more in the documentation for iOS Spline smoothing Line Series.

See also: Spline Line Series and Spline Mountain Series as well.

The Swift and Objective-C source code for the iOS and macOS Spline Band Chart example is included below (Scroll down!).

Did you know that we have the source code for all our example available for free on Github?

Clone the SciChart.iOS.Examples from Github.

Also the SciChart iOS and Scichart macOS Trials contain the full source for the examples (link below).

DOWNLOAD THE IOS CHART EXAMPLES

SplineBandChartView.m
View source code
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2019. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales:   sales@scichart.com
//
// SplineBandChartView.m is part of the SCICHART® Examples. Permission is hereby granted
// to modify, create derivative works, distribute and publish any part of this source
// code whether for commercial, private or personal use.
//
// The SCICHART® examples are distributed in the hope that they will be useful, but
// without any warranty. It is provided "AS IS" without warranty of any kind, either
// expressed or implied.
//******************************************************************************

#import "SplineBandChartView.h"
#import "SCDDataManager.h"

@implementation SplineBandChartView

- (Class)associatedType { return SCIChartSurface.class; }

- (void)initExample {
    id<ISCIAxis> xAxis = [SCINumericAxis new];
    xAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.1 max:0.1];
    
    id<ISCIAxis> yAxis = [SCINumericAxis new];
    yAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.2 max:0.2];
    
    SCDDoubleSeries *data = [SCDDataManager getDampedSinewaveWithAmplitude:1.0 DampingFactor:0.005 PointCount:1000 Freq:13];
    SCDDoubleSeries *moreData = [SCDDataManager getDampedSinewaveWithAmplitude:1.0 DampingFactor:0.005 PointCount:1000 Freq:12];
    
    SCIXyyDataSeries *dataSeries = [[SCIXyyDataSeries alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double];
    for (int i = 0; i < 10; i++) {
        int index = i * 100;
        double x = [data.xValues getValueAt:index];
        double y = [data.yValues getValueAt:index];
        double y1 = [moreData.yValues getValueAt:index];
        [dataSeries appendX:@(x) y:@(y) y1:@(y1)];
    }
    
    SCIEllipsePointMarker *ellipsePointMarker = [SCIEllipsePointMarker new];
    ellipsePointMarker.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xFF68bcae thickness:1.0 strokeDashArray:NULL antiAliasing:YES];
    ellipsePointMarker.fillStyle = [[SCISolidBrushStyle alloc] initWithColorCode:0xFFFFFFFF];
    ellipsePointMarker.size = CGSizeMake(7, 7);
    
    SCISplineBandRenderableSeries *rSeries = [SCISplineBandRenderableSeries new];
    rSeries.dataSeries = dataSeries;
    rSeries.pointMarker = ellipsePointMarker;
    rSeries.fillBrushStyle = [[SCISolidBrushStyle alloc] initWithColorCode:0x3350C7E0];
    rSeries.fillY1BrushStyle = [[SCISolidBrushStyle alloc] initWithColorCode:0x33F48420];
    rSeries.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xFF50C7E0 thickness:2.0];
    rSeries.strokeY1Style = [[SCISolidPenStyle alloc] initWithColorCode:0xFFF48420 thickness:2.0];
    
    SCIElasticEase* easingFunction = [SCIElasticEase new];
    easingFunction.springiness = 5;
    easingFunction.oscillations = 1;
    
    [SCIUpdateSuspender usingWithSuspendable:self.surface withBlock:^{
        [self.surface.xAxes add:xAxis];
        [self.surface.yAxes add:yAxis];
        [self.surface.renderableSeries add:rSeries];
        [self.surface.chartModifiers add:[SCDExampleBaseViewController createDefaultModifiers]];

        [SCIAnimations scaleSeries:rSeries duration:1.0 andEasingFunction:easingFunction];
    }];
}

@end
SplineBandChartView.swift
View source code
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2020. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales:   sales@scichart.com
//
// SplineBandChartView.swift is part of the SCICHART® Examples. Permission is hereby granted
// to modify, create derivative works, distribute and publish any part of this source
// code whether for commercial, private or personal use.
//
// The SCICHART® examples are distributed in the hope that they will be useful, but
// without any warranty. It is provided "AS IS" without warranty of any kind, either
// expressed or implied.
//******************************************************************************

class SplineBandChartView: SCDSingleChartViewController<SCIChartSurface> {
    
    override var associatedType: AnyClass { return SCIChartSurface.self }
    
    override func initExample() {
        let xAxis = SCINumericAxis()
        xAxis.growBy = SCIDoubleRange(min: 0.1, max: 0.1)
        
        let yAxis = SCINumericAxis()
        yAxis.growBy = SCIDoubleRange(min: 0.2, max: 0.2)
        
        let data = SCDDataManager.getDampedSinewave(withAmplitude: 1.0, dampingFactor: 0.005, pointCount: 1000, freq: 13)
        let moreData = SCDDataManager.getDampedSinewave(withAmplitude: 1.0, dampingFactor: 0.005, pointCount: 1000, freq: 12)
        
        let dataSeries = SCIXyyDataSeries(xType: .double, yType: .double)
        for i in 0 ..< 10 {
            let index = i * 100
            dataSeries.append(x: data.xValues.getValueAt(index), y: data.yValues.getValueAt(index), y1: moreData.yValues.getValueAt(index))
        }
        
        let ellipsePointMarker = SCIEllipsePointMarker()
        ellipsePointMarker.strokeStyle = SCISolidPenStyle(color: 0xFF68bcae, thickness: 1.0)
        ellipsePointMarker.fillStyle = SCISolidBrushStyle(color: 0xFFFFFFFF)
        ellipsePointMarker.size = CGSize(width: 7, height: 7)
        
        let rSeries = SCISplineBandRenderableSeries()
        rSeries.dataSeries = dataSeries
        rSeries.pointMarker = ellipsePointMarker
        rSeries.fillBrushStyle = SCISolidBrushStyle(color: 0x3350C7E0)
        rSeries.fillY1BrushStyle = SCISolidBrushStyle(color: 0x33F48420)
        rSeries.strokeStyle =  SCISolidPenStyle(color: 0xFF50C7E0, thickness: 2.0)
        rSeries.strokeY1Style = SCISolidPenStyle(color: 0xFFF48420, thickness: 2.0)
        
        let easingFunction = SCIElasticEase()
        easingFunction.oscillations = 1
        easingFunction.springiness = 5        
        
        SCIUpdateSuspender.usingWith(surface) {
            self.surface.xAxes.add(xAxis)
            self.surface.yAxes.add(yAxis)
            self.surface.renderableSeries.add(items: rSeries)
            self.surface.chartModifiers.add(SCDExampleBaseViewController.createDefaultModifiers())

            SCIAnimations.scale(rSeries, duration: 1.0, andEasingFunction: easingFunction)
        }
    }
}
Back to iOS & macOS charts Examples