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.
In SciChart iOS 3D you can create a Mesh of any shape or size & define its location as well as set different palette modes (Radial, Axial, Polar and Azimuthal). This example demonstrates how to use SCICustomSurfaceDataSeries3D and SCIFreeSurfaceRenderableSeries3D to render Custom 3D Free Surface Mesh in iOS SWIFT and Obj-C with SciChart.
These chart types are used extensively among the scientific & engineering sectors as well as across iOS SWIFT Chart heavy applications.
You can read more about creating an iOS custom free surface mesh 3D chart and other mesh types in SciChart iOS 3D Documentation and Tutorials:
The Swift and Objective-C source code for the iOS and macOS Create Custom Free Surface 3D 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
//
// CustomFreeSurface3DChartView.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 "CustomFreeSurface3DChartView.h"
@implementation CustomFreeSurface3DChartView
- (Class)associatedType { return SCIChartSurface3D.class; }
- (void)initExample {
SCINumericAxis3D *xAxis = [SCINumericAxis3D new];
xAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.1 max:0.1];
SCINumericAxis3D *yAxis = [SCINumericAxis3D new];
yAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.1 max:0.1];
SCINumericAxis3D *zAxis = [SCINumericAxis3D new];
zAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.1 max:0.1];
SCIUVFunc radialDistanceFunc = ^(double u, double v) { return 5.0 + sin(5.0 * (u + v)); };
SCIUVFunc azimuthalAngleFunc = ^(double u, double v) { return u; };
SCIUVFunc polarAngleFunc = ^(double u, double v) { return v; };
SCIValueFunc xFunc = ^(double r, double theta, double phi) { return r * sin(theta) * cos(phi); };
SCIValueFunc yFunc = ^(double r, double theta, double phi) { return r * cos(theta); };
SCIValueFunc zFunc = ^(double r, double theta, double phi) { return r * sin(theta) * sin(phi); };
SCICustomSurfaceDataSeries3D *ds = [[SCICustomSurfaceDataSeries3D alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double zType:SCIDataType_Double uSize:30 vSize:30 radialDistanceFunc:radialDistanceFunc azimuthalAngleFunc:azimuthalAngleFunc polarAngleFunc:polarAngleFunc xFunc:xFunc yFunc:yFunc zFunc:zFunc];
unsigned int colors[7] = { 0xFF00008B, 0xFF0000FF, 0xFF00FFFF, 0xFFADFF2F, 0xFFFFFF00, 0xFFFF0000, 0xFF8B0000 };
float stops[7] = { 0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0};
SCIGradientColorPalette *palette = [[SCIGradientColorPalette alloc] initWithColors:colors stops:stops count:7];
SCIFreeSurfaceRenderableSeries3D *rSeries = [SCIFreeSurfaceRenderableSeries3D new];
rSeries.dataSeries = ds;
rSeries.drawMeshAs = SCIDrawMeshAs_SolidWireframe;
rSeries.stroke = 0x77228B22;
rSeries.contourInterval = 0.1;
rSeries.contourStroke = 0x77228B22;
rSeries.strokeThickness = 2.0;
rSeries.lightingFactor = 0.8;
rSeries.meshColorPalette = palette;
rSeries.paletteMinMaxMode = SCIFreeSurfacePaletteMinMaxMode_Relative;
rSeries.paletteMinimum = [[SCIVector3 alloc] initWithX:0.0 y:5.0 z:0.0];
rSeries.paletteMaximum = [[SCIVector3 alloc] initWithX:0.0 y:7.0 z:0.0];
[SCIUpdateSuspender usingWithSuspendable:self.surface withBlock:^{
self.surface.xAxis = xAxis;
self.surface.yAxis = yAxis;
self.surface.zAxis = zAxis;
[self.surface.renderableSeries add:rSeries];
[self.surface.chartModifiers add:[SCDExampleBaseViewController createDefaultModifiers3D]];
}];
}
@end
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2019. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// CustomFreeSurface3DChartView.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 CustomFreeSurface3DChartView: SCDSingleChartViewController<SCIChartSurface3D> {
override var associatedType: AnyClass { return SCIChartSurface3D.self }
override func initExample() {
let xAxis = SCINumericAxis3D()
xAxis.growBy = SCIDoubleRange(min: 0.1, max: 0.1)
let yAxis = SCINumericAxis3D()
yAxis.growBy = SCIDoubleRange(min: 0.1, max: 0.1)
let zAxis = SCINumericAxis3D()
zAxis.growBy = SCIDoubleRange(min: 0.1, max: 0.1)
let radialDistanceFunc: SCIUVFunc = { u, v in 5.0 + sin(5.0 * (u + v)) }
let azimuthalAngleFunc: SCIUVFunc = { u, _ in u }
let polarAngleFunc: SCIUVFunc = { _, v in v }
let xFunc: SCIValueFunc = { r, theta, phi in r * sin(theta) * cos(phi) }
let yFunc: SCIValueFunc = { r, theta, phi in r * cos(theta) }
let zFunc: SCIValueFunc = { r, theta, phi in r * sin(theta) * sin(phi) }
let ds = SCICustomSurfaceDataSeries3D(xType: .double, yType: .double, zType: .double, uSize: 30, vSize: 30, radialDistanceFunc: radialDistanceFunc, azimuthalAngleFunc: azimuthalAngleFunc, polarAngleFunc: polarAngleFunc, xFunc: xFunc, yFunc: yFunc, zFunc: zFunc, uMin: 0.0, uMax: Double.pi * 2, vMin: 0, vMax: Double.pi)
let palette = SCIGradientColorPalette(
colors: [0xFF00008B, 0xFF0000FF, 0xFF00FFFF, 0xFFADFF2F, 0xFFFFFF00, 0xFFFF0000, 0xFF8B0000],
stops: [0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0]
)
let rSeries = SCIFreeSurfaceRenderableSeries3D()
rSeries.dataSeries = ds
rSeries.drawMeshAs = .solidWireframe
rSeries.stroke = 0x77228B22
rSeries.contourInterval = 0.1
rSeries.contourStroke = 0x77228B22
rSeries.strokeThickness = 2.0
rSeries.lightingFactor = 0.8
rSeries.meshColorPalette = palette
rSeries.paletteMinMaxMode = .relative
rSeries.paletteMinimum = SCIVector3(x: 0.0, y: 5.0, z: 0.0)
rSeries.paletteMaximum = SCIVector3(x: 0.0, y: 7.0, z: 0.0)
SCIUpdateSuspender.usingWith(surface) {
self.surface.xAxis = xAxis
self.surface.yAxis = yAxis
self.surface.zAxis = zAxis
self.surface.renderableSeries.add(rSeries)
self.surface.chartModifiers.add(SCDExampleBaseViewController.createDefaultModifiers3D())
}
}
}