SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
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.
This example showcases how to create Spline Mountain (Area) Series that is provided by the SCISplineMountainRenderableSeries type. The iOS Spline Mountain Series can be used when the raw data has too many points and displaying it all it is makes the chart difficult to read, makes finding the trends very hard as well. The smoothing gives the charts in your iOS applications slick looks and a good user experience to your customers.
Spline Mountain Series Features:
Read more in the documentation for iOS Spline smoothing Mountain Series.
See also: Spline Line Series and Spline Band Series as well.
The Swift and Objective-C source code for the iOS and macOS Spline Mountain 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).
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2019. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// SplineMountainChartView.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 "SplineMountainChartView.h"
@implementation SplineMountainChartView
- (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 max:0.2];
SCIXyDataSeries *dataSeries = [[SCIXyDataSeries alloc] initWithXType:SCIDataType_Int yType:SCIDataType_Int];
int yValues[] = {50, 35, 61, 58, 50, 50, 40, 53, 55, 23, 45, 12, 59, 60};
for (unsigned long i = 0; i < sizeof(yValues)/sizeof(yValues[0]); i++) {
[dataSeries appendX:@(i) y:@(yValues[i])];
}
SCIEllipsePointMarker *ellipsePointMarker = [SCIEllipsePointMarker new];
ellipsePointMarker.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xFF006400 thickness:1.0 strokeDashArray:NULL antiAliasing:YES];
ellipsePointMarker.fillStyle = [[SCISolidBrushStyle alloc] initWithColorCode:0xFFFFFFFF];
ellipsePointMarker.size = CGSizeMake(7, 7);
SCISplineMountainRenderableSeries *rSeries = [SCISplineMountainRenderableSeries new];
rSeries.dataSeries = dataSeries;
rSeries.pointMarker = ellipsePointMarker;
rSeries.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xAAFFC9A8 thickness:1.0 strokeDashArray:NULL antiAliasing:YES];
rSeries.areaStyle = [[SCILinearGradientBrushStyle alloc] initWithStartColorCode:0xAAFF8D42 endColorCode:0x88090E11];
[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 waveSeries:rSeries duration:3.0 andEasingFunction:[SCICubicEase new]];
}];
}
@end
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2020. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// SplineMountainChartView.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 SplineMountainChartView: SCDSingleChartViewController<SCIChartSurface> {
override var associatedType: AnyClass { return SCIChartSurface.self }
override func initExample() {
let xBottomAxis = SCINumericAxis()
xBottomAxis.growBy = SCIDoubleRange(min: 0.1, max: 0.1)
let yRightAxis = SCINumericAxis()
yRightAxis.growBy = SCIDoubleRange(min: 0, max: 0.2)
let dataSeries = SCIXyDataSeries(xType: .int, yType: .int)
let yValues = [50, 35, 61, 58, 50, 50, 40, 53, 55, 23, 45, 12, 59, 60]
for i in 0 ..< yValues.count {
dataSeries.append(x: i, y: yValues[i])
}
let ellipsePointMarker = SCIEllipsePointMarker()
ellipsePointMarker.strokeStyle = SCISolidPenStyle(color: 0xFF006400, thickness: 1.0)
ellipsePointMarker.fillStyle = SCISolidBrushStyle(color: 0xFFFFFFFF)
ellipsePointMarker.size = CGSize(width: 7, height: 7)
let rSeries = SCISplineMountainRenderableSeries()
rSeries.dataSeries = dataSeries
rSeries.pointMarker = ellipsePointMarker
rSeries.strokeStyle = SCISolidPenStyle(color: 0xAAFFC9A8, thickness: 1.0, strokeDashArray: nil, antiAliasing: true)
rSeries.areaStyle = SCILinearGradientBrushStyle(startColor: 0xAAFF8D42, endColor: 0x88090E11)
SCIUpdateSuspender.usingWith(surface) {
self.surface.xAxes.add(xBottomAxis)
self.surface.yAxes.add(yRightAxis)
self.surface.renderableSeries.add(items: rSeries)
self.surface.chartModifiers.add(SCDExampleBaseViewController.createDefaultModifiers())
SCIAnimations.wave(rSeries, duration: 3.0, andEasingFunction: SCICubicEase())
}
}
}