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.
Demonstrates how to use SCIColumnRenderableSeries3D class and create a 3D Uniform Column Chart in SciChart iOS. It accepts either XyzDataSeries3D for sparse points, or UniformGridDataSeries3D for an NxM array of points.
The SciChart iOS 3D API is flexible to allow you have different number of column rows, size, and shapes. Column shares are provided by the PointMarkers API and include following out of the box: SpherePointMarker3D, CubePointMarker3D, PyramidPointMarker3D, CylinderPointMarker3D.
Please read more about Column Chart type in iOS and its functionality in our documentation:
The Swift and Objective-C source code for the iOS and macOS Uniform Column Chart 3D 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
//
// ColumnChartView.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 "ColumnChartView.h"
#import "SCDDataManager.h"
@interface ColumnsTripleColorPalette : SCIPaletteProviderBase<SCIFastColumnRenderableSeries *><ISCIFillPaletteProvider>
- (instancetype)init;
@end
@implementation ColumnsTripleColorPalette {
SCIUnsignedIntegerValues *_colors;
}
static unsigned int desiredColors[] = {0xFFa9d34f, 0xFFfc9930, 0xFFd63b3f};
- (instancetype)init {
self = [super initWithRenderableSeriesType:SCIFastColumnRenderableSeries.class];
if (self) {
_colors = [SCIUnsignedIntegerValues new];
}
return self;
}
- (void)update {
NSInteger count = self.renderableSeries.currentRenderPassData.pointsCount;
_colors.count = count;
unsigned int *colorsArray = _colors.itemsArray;
for (NSInteger i = 0; i < count; i++) {
colorsArray[i] = desiredColors[i % 3];
}
}
- (SCIUnsignedIntegerValues *)fillColors {
return _colors;
}
@end
@implementation ColumnChartView
- (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.0 max:0.1];
SCIXyDataSeries *dataSeries = [[SCIXyDataSeries alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double];
int yValues[] = {50, 35, 61, 58, 50, 50, 40, 53, 55, 23, 45, 12, 59, 60};
for (size_t i = 0; i < sizeof(yValues)/sizeof(yValues[0]); i++) {
[dataSeries appendX:@(i) y:@(yValues[i])];
}
SCIFastColumnRenderableSeries *rSeries = [SCIFastColumnRenderableSeries new];
rSeries.dataSeries = dataSeries;
rSeries.paletteProvider = [ColumnsTripleColorPalette new];
[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-2019. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// ColumnChartView.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 ColumnsTripleColorPalette : SCIPaletteProviderBase<SCIFastColumnRenderableSeries>, ISCIFillPaletteProvider {
let colors = SCIUnsignedIntegerValues()
let desiredColors:[UInt32] = [0xffa9d34f, 0xfffc9930, 0xffd63b3f]
init() {
super.init(renderableSeriesType: SCIFastColumnRenderableSeries.self)
}
override func update() {
let count = renderableSeries!.currentRenderPassData.pointsCount
colors.count = count
for i in 0 ..< count {
colors.set(desiredColors[i % 3], at: i)
}
}
var fillColors: SCIUnsignedIntegerValues { return colors }
}
class ColumnChartView: 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, max: 0.1)
let dataSeries = SCIXyDataSeries(xType: .double, yType: .double)
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 rSeries = SCIFastColumnRenderableSeries()
rSeries.dataSeries = dataSeries
rSeries.paletteProvider = ColumnsTripleColorPalette()
SCIUpdateSuspender.usingWith(surface) {
self.surface.xAxes.add(xAxis)
self.surface.yAxes.add(yAxis)
self.surface.renderableSeries.add(rSeries)
self.surface.chartModifiers.add(SCDExampleBaseViewController.createDefaultModifiers())
SCIAnimations.wave(rSeries, duration: 3.0, andEasingFunction: SCICubicEase())
}
}
}