Pre loader

iOS & macOS Vertical Charts Example

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

This example demonstrates a vertical iOS chart with XAxis on the Left, Right, and YAxes at the Top. SciChart iOS supports unlimited X and Y axis and allows placement of any axis on the Left, Right, Top, Bottom of the chart.

The Vertical Chart is created by setting XAxis.axisAlignment = SCIAxisAlignment_Left, and YAxis.axisAlignment = SCIAxisAlignment_Top

This type of chart is useful in the Oil & Gas industry, where iOS Charts might be used to visualize Drill Depth.

The Swift and Objective-C source code for the iOS and macOS Vertical Charts Example 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

VerticalChartView.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
//
// VerticalChartView.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 VerticalChartView: SCDSingleChartViewController<SCIChartSurface> {
    
    override var associatedType: AnyClass { return SCIChartSurface.self }
    
    override var showDefaultModifiersInToolbar: Bool { return false }

    override func initExample() {
        let xAxis = SCINumericAxis()
        xAxis.axisAlignment = .left
        xAxis.axisTitle = "X-Axis"
        
        let yAxis = SCINumericAxis()
        yAxis.axisAlignment = .top
        yAxis.axisTitle = "Y-Axis"
        
        let dataSeries0 = SCIXyDataSeries(xType: .double, yType: .double)
        let dataSeries1 = SCIXyDataSeries(xType: .double, yType: .double)
        
        let doubleSeries = SCDDoubleSeries(capacity: 20)
        SCDDataManager.setRandomDoubleSeries(doubleSeries, count: 20)
        dataSeries0.append(x: doubleSeries.xValues, y: doubleSeries.yValues)
        
        doubleSeries.xValues.clear()
        doubleSeries.yValues.clear()
        
        SCDDataManager.setRandomDoubleSeries(doubleSeries, count: 20)
        dataSeries1.append(x: doubleSeries.xValues, y: doubleSeries.yValues)
        
        let lineSeries0 = SCIFastLineRenderableSeries()
        lineSeries0.dataSeries = dataSeries0
        lineSeries0.strokeStyle = SCISolidPenStyle(color: 0xFF47bde6, thickness: 1.0)
        
        let lineSeries1 = SCIFastLineRenderableSeries()
        lineSeries1.dataSeries = dataSeries1
        lineSeries1.strokeStyle = SCISolidPenStyle(color: 0xFF68bcae, thickness: 1.0)
        
        SCIUpdateSuspender.usingWith(surface) {
            self.surface.xAxes.add(xAxis)
            self.surface.yAxes.add(yAxis)
            self.surface.renderableSeries.add(lineSeries0)
            self.surface.renderableSeries.add(lineSeries1)
            self.surface.chartModifiers.add(SCDExampleBaseViewController.createDefaultModifiers())
            
            SCIAnimations.sweep(lineSeries0, duration: 3.0, easingFunction: SCICubicEase())
            SCIAnimations.sweep(lineSeries1, duration: 3.0, easingFunction: SCICubicEase())
        }
    }
}
VerticalChartView.swift
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
//
// VerticalChartView.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 "VerticalChartView.h"
#import "SCDDataManager.h"

@implementation VerticalChartView

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

- (BOOL)showDefaultModifiersInToolbar { return NO; }

- (void)initExample {
    id<ISCIAxis> xAxis = [SCINumericAxis new];
    xAxis.axisAlignment = SCIAxisAlignment_Left;
    xAxis.axisTitle = @"X-Axis";
    
    id<ISCIAxis> yAxis = [SCINumericAxis new];
    yAxis.axisAlignment = SCIAxisAlignment_Top;
    yAxis.axisTitle = @"Y-Axis";
    
    SCIXyDataSeries *dataSeries0 = [[SCIXyDataSeries alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double];
    SCIXyDataSeries *dataSeries1 = [[SCIXyDataSeries alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double];
    
    SCDDoubleSeries *doubleSeries = [[SCDDoubleSeries alloc] initWithCapacity:20];
    [SCDDataManager setRandomDoubleSeries:doubleSeries count:20];
    [dataSeries0 appendValuesX:doubleSeries.xValues y:doubleSeries.yValues];
    
    [doubleSeries.xValues clear];
    [doubleSeries.yValues clear];
    
    [SCDDataManager setRandomDoubleSeries:doubleSeries count:20];
    [dataSeries1 appendValuesX:doubleSeries.xValues y:doubleSeries.yValues];
    
    SCIFastLineRenderableSeries *lineSeries0 = [SCIFastLineRenderableSeries new];
    lineSeries0.dataSeries = dataSeries0;
    lineSeries0.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xFF47bde6 thickness:2.0];
    
    SCIFastLineRenderableSeries *lineSeries1 = [SCIFastLineRenderableSeries new];
    lineSeries1.dataSeries = dataSeries1;
    lineSeries1.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xFF68bcae thickness:2.0];
        
    [SCIUpdateSuspender usingWithSuspendable:self.surface withBlock:^{
        [self.surface.xAxes add:xAxis];
        [self.surface.yAxes add:yAxis];
        [self.surface.renderableSeries add:lineSeries0];
        [self.surface.renderableSeries add:lineSeries1];
        [self.surface.chartModifiers add:[SCDExampleBaseViewController createDefaultModifiers]];
        
        [SCIAnimations sweepSeries:lineSeries0 duration:3.0 andEasingFunction:[SCICubicEase new]];
        [SCIAnimations sweepSeries:lineSeries1 duration:3.0 andEasingFunction:[SCICubicEase new]];
    }];
}

@end
Back to iOS & macOS charts Examples