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.
SciChart iOS features a variety of chart types out of the box. This example demonstrates how to use SCIScatterRenderableSeries3D and how to create a 3D Bubble iOS SWIFT Chart or Obj-C chart with SciChart iOS Chart Library. You can set the shape of scatters with help of PointMarkers, these include: Sphere, Cube, Pyramid and Cylinder; as well as scatters size and color.
You can read more about how to create an iOS Bubble Chart in SciChart iOS 3D documentation: Scatter 3D Chart Type.
The Swift and Objective-C source code for the iOS and macOS Simple Bubble 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
//
// Bubbles3DChartView.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 "Bubbles3DChartView.h"
#import "SCDDataManager.h"
@implementation Bubbles3DChartView
- (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];
SCIXyzDataSeries3D *ds = [[SCIXyzDataSeries3D alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double zType:SCIDataType_Double];
SCIPointMetadataProvider3D *metadataProvider = [SCIPointMetadataProvider3D new];
for (int i = 0; i < 250; ++i) {
double x = [SCDDataManager getGaussianRandomNumber:15 stdDev:1.5];
double y = [SCDDataManager getGaussianRandomNumber:15 stdDev:1.5];
double z = [SCDDataManager getGaussianRandomNumber:15 stdDev:1.5];
[ds appendX:@(x) y:@(y) z:@(z)];
SCIPointMetadata3D *metaData = [[SCIPointMetadata3D alloc] initWithVertexColor:[SCDDataManager randomColor] andScale:[SCDDataManager randomScale]];
[metadataProvider.metadata addObject:metaData];
}
SCISpherePointMarker3D *pointMarker = [SCISpherePointMarker3D new];
pointMarker.fillColor = 0x77ADFF2F;
pointMarker.size = 3.f;
SCIScatterRenderableSeries3D *rSeries = [SCIScatterRenderableSeries3D new];
rSeries.dataSeries = ds;
rSeries.pointMarker = pointMarker;
rSeries.metadataProvider = metadataProvider;
[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
//
// Bubbles3DChartView.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 Bubbles3DChartView: 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 dataSeries = SCIXyzDataSeries3D(xType: .double, yType: .double, zType: .double)
let pointMetaDataProvider = SCIPointMetadataProvider3D()
for _ in 0 ..< 250 {
let x = SCDDataManager.getGaussianRandomNumber(5, stdDev: 1.5)
let y = SCDDataManager.getGaussianRandomNumber(5, stdDev: 1.5)
let z = SCDDataManager.getGaussianRandomNumber(5, stdDev: 1.5)
dataSeries.append(x: x, y: y, z: z);
let metadata = SCIPointMetadata3D(vertexColor: SCDDataManager.randomColor(), andScale: SCDDataManager.randomScale())
pointMetaDataProvider.metadata.add(metadata)
}
let pointMarker = SCISpherePointMarker3D()
pointMarker.fillColor = 0x77ADFF2F
pointMarker.size = 3.0
let rSeries = SCIScatterRenderableSeries3D()
rSeries.dataSeries = dataSeries
rSeries.pointMarker = pointMarker
rSeries.metadataProvider = pointMetaDataProvider
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())
}
}
}