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.
This example demonstrates how to add tooltips to a series on a SciChart iOS 3D Charts.
Read more about Tooltip Modifier in iOS 3D in SciChart documentation and tutorials about Cursor and Tooltips in 3D.
The Swift and Objective-C source code for the iOS and macOS Series Tooltips 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).
SeriesTooltip3DChartView.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
//
// SeriesTooltip3DChartView.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 "SeriesTooltip3DChartView.h"
#include <GLKit/GLKMathUtils.h>
unsigned int BlueColor = 0xFF0084CF;
unsigned int RedColor = 0xFFEE1110;
int SegmentsCount = 25;
#define YAngle GLKMathDegreesToRadians(-65)
#define CosYAngle cos(YAngle)
#define SinYAngle sin(YAngle)
@implementation SeriesTooltip3DChartView
- (Class)associatedType { return SCIChartSurface3D.class; }
- (void)initExample {
SCINumericAxis3D *xAxis = [SCINumericAxis3D new];
xAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.2 max:0.2];
xAxis.maxAutoTicks = 5;
xAxis.axisTitle = @"X - Axis";
SCINumericAxis3D *yAxis = [SCINumericAxis3D new];
yAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.1 max:0.1];
yAxis.axisTitle = @"Y - Axis";
SCINumericAxis3D *zAxis = [SCINumericAxis3D new];
zAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.2 max:0.2];
zAxis.axisTitle = @"Z - Axis";
SCIXyzDataSeries3D *ds = [[SCIXyzDataSeries3D alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double zType:SCIDataType_Double];
SCIPointMetadataProvider3D *metadataProvider = [SCIPointMetadataProvider3D new];
double rotationAngle = 360.0 / 45.0;
double currentAngle = 0.0;
for (int i = (-SegmentsCount); i < (SegmentsCount + 1); i++) {
[self appendPoint:ds x:-4 y:i currentAngle:currentAngle];
[self appendPoint:ds x:4 y:i currentAngle:currentAngle];
SCIPointMetadata3D *metaData1 = [[SCIPointMetadata3D alloc] initWithVertexColor:BlueColor andScale:1.0];
[metadataProvider.metadata addObject:metaData1];
SCIPointMetadata3D *metaData2 = [[SCIPointMetadata3D alloc] initWithVertexColor:RedColor andScale:1.0];
[metadataProvider.metadata addObject:metaData2];
currentAngle = (int)(currentAngle + rotationAngle) % 360;
}
SCISpherePointMarker3D *pointMarker = [SCISpherePointMarker3D new];
pointMarker.size = 8.f;
SCIPointLineRenderableSeries3D *rSeries = [SCIPointLineRenderableSeries3D new];
rSeries.dataSeries = ds;
rSeries.pointMarker = pointMarker;
rSeries.metadataProvider = metadataProvider;
rSeries.isLineStrips = NO;
rSeries.strokeThickness = 4.0;
SCITooltipModifier3D *toolTipModifier = [SCITooltipModifier3D new];
toolTipModifier.receiveHandledEvents = YES;
toolTipModifier.crosshairMode = SCICrosshairMode_Lines;
toolTipModifier.crosshairPlanesFill = [SCIColor fromARGBColorCode:0x33FF6600];
[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 addAll:toolTipModifier, [SCIPinchZoomModifier3D new], [SCIZoomExtentsModifier3D new], [[SCIOrbitModifier3D alloc] initWithDefaultNumberOfTouches:2], nil];
self.surface.camera = [SCICamera3D new];
[self.surface.camera.position assignX:-160 y:190 z:-520];
[self.surface.camera.target assignX:-45 y:150 z:0];
[self.surface.worldDimensions assignX:600 y:300 z:180];
}];
}
- (void)appendPoint:(SCIXyzDataSeries3D *)ds x:(double)x y:(double)y currentAngle:(double)currentAngle {
double radAngle = GLKMathDegreesToRadians(currentAngle);
double temp = x * cos(radAngle);
double xValue = temp * CosYAngle - y * SinYAngle;
double yValue = temp * SinYAngle + y * CosYAngle;
double zValue = x * sin(radAngle);
[ds appendX:@(xValue) y:@(yValue) z:@(zValue)];
}
@end
SeriesTooltip3DChartView.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
//
// SeriesTooltip3DChartView.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.
//******************************************************************************
private let BlueColor: UInt32 = 0xFF0084CF
private let RedColor: UInt32 = 0xFFEE1110
private let SegmentsCount = 25
private let YAngle: Double = -65 * (.pi / 180)
private let CosYAngle: Double = cos(YAngle)
private let SinYAngle: Double = sin(YAngle)
class SeriesTooltip3DChartView: SCDSingleChartViewController<SCIChartSurface3D> {
override var associatedType: AnyClass { return SCIChartSurface3D.self }
override func initExample() {
let xAxis = SCINumericAxis3D()
xAxis.growBy = SCIDoubleRange(min: 0.2, max: 0.2)
xAxis.maxAutoTicks = 5
xAxis.axisTitle = "X - Axis"
let yAxis = SCINumericAxis3D()
yAxis.growBy = SCIDoubleRange(min: 0.1, max: 0.1)
yAxis.axisTitle = "Y - Axis"
let zAxis = SCINumericAxis3D()
zAxis.growBy = SCIDoubleRange(min: 0.2, max: 0.2)
zAxis.axisTitle = "Z - Axis"
let pointMetadataProvider = SCIPointMetadataProvider3D()
let dataSeries = SCIXyzDataSeries3D(xType: .double, yType: .double, zType: .double)
let RotationAngle: Double = 360.0 / 45.0
var currentAngle: Double = 0.0
for i in -SegmentsCount ..< SegmentsCount + 1 {
appendPoint(dataSeries, x: -4, y: Double(i), currentAngle: currentAngle)
appendPoint(dataSeries, x: 4, y: Double(i), currentAngle: currentAngle)
pointMetadataProvider.metadata.add(SCIPointMetadata3D(vertexColor: BlueColor, andScale: 1))
pointMetadataProvider.metadata.add(SCIPointMetadata3D(vertexColor: RedColor, andScale: 1))
currentAngle = (currentAngle + RotationAngle).truncatingRemainder(dividingBy: 360.0)
}
let pointMarker = SCISpherePointMarker3D()
pointMarker.size = 8.0
let rSeries = SCIPointLineRenderableSeries3D()
rSeries.dataSeries = dataSeries
rSeries.strokeThickness = 4.0
rSeries.pointMarker = pointMarker
rSeries.isLineStrips = false
rSeries.metadataProvider = pointMetadataProvider
let tooltipModifier = SCITooltipModifier3D()
tooltipModifier.receiveHandledEvents = true
tooltipModifier.crosshairMode = .lines
tooltipModifier.crosshairPlanesFill = SCIColor.fromARGBColorCode(0x33FF6600)
SCIUpdateSuspender.usingWith(surface) {
self.surface.xAxis = xAxis
self.surface.yAxis = yAxis
self.surface.zAxis = zAxis
self.surface.renderableSeries.add(rSeries)
self.surface.chartModifiers.add(items: tooltipModifier, SCIPinchZoomModifier3D(), SCIZoomExtentsModifier3D(), SCIOrbitModifier3D(defaultNumberOfTouches: 2))
self.surface.camera = SCICamera3D()
self.surface.camera.position.assignX(-160, y: 190, z: -520)
self.surface.camera.target.assignX(-45, y: 150, z: 0)
self.surface.worldDimensions.assignX(600, y: 300, z: 180)
}
}
private func appendPoint(_ ds: SCIXyzDataSeries3D, x: Double, y: Double, currentAngle: Double) {
let radAngle = currentAngle * (.pi / 180)
let temp = x * Double(cos(radAngle))
let xValue = temp * CosYAngle - y * SinYAngle;
let yValue = temp * SinYAngle + y * CosYAngle;
let zValue = x * Double(sin(radAngle))
ds.append(x: xValue, y: yValue, z: zValue)
}
}
Back to iOS & macOS charts Examples


