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.
To see more details about the chart we provide tooltips, crosshairs and labels. This example shows that you can customize the look and feel of Tooltips in SciChart iOS 3D to meet your needs.
Read more about Tooltip Modifier in iOS 3D in SciChart documentation and tutorials.
The Swift and Objective-C source code for the iOS and macOS Custom 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).
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2019. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// CustomSeriesTooltip3DChartView.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 "CustomSeriesTooltip3DChartView.h"
#import <SciChart/SCISeriesTooltip3DBase+Protected.h>
#import <SciChart/SCISeriesInfo3DProviderBase+Protected.h>
#import "SCDDataManager.h"
#import "SCDRandomUtil.h"
@interface CustomXyzSerieesTooltip3D : SCIXyzSeriesTooltip3D
@end
@implementation CustomXyzSerieesTooltip3D
- (void)internalUpdate:(SCISeriesInfo3D *)seriesInfo {
NSMutableString *tootlipText = @"This is Custom Tooltip \n".mutableCopy;
[tootlipText appendFormat:@"Vertex id: %d\n", ((SCIXyzSeriesInfo3D *)seriesInfo).vertexId];
[tootlipText appendFormat:@"X: %@\n", seriesInfo.formattedXValue.rawString];
[tootlipText appendFormat:@"Y: %@\n", seriesInfo.formattedYValue.rawString];
[tootlipText appendFormat:@"Z: %@", seriesInfo.formattedZValue.rawString];
self.text = tootlipText;
[self setSeriesColor:seriesInfo.seriesColor.colorARGBCode];
}
@end
@interface CustomSeriesInfo3DProvider : SCIDefaultXyzSeriesInfo3DProvider
@end
@implementation CustomSeriesInfo3DProvider
- (id<ISCISeriesTooltip3D>)getSeriesTooltipInternalWithSeriesInfo:(SCISeriesInfo3D *)seriesInfo modifierType:(Class)modifierType {
if (modifierType == SCITooltipModifier3D.class) {
return [[CustomXyzSerieesTooltip3D alloc] initWithSeriesInfo:seriesInfo];
} else {
return [super getSeriesTooltipInternalWithSeriesInfo:seriesInfo modifierType:modifierType];
}
}
@end
@implementation CustomSeriesTooltip3DChartView
- (Class)associatedType { return SCIChartSurface3D.class; }
- (void)initExample {
SCINumericAxis3D *xAxis = [SCINumericAxis3D new];
xAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.2 max:0.2];
xAxis.visibleRange = [[SCIDoubleRange alloc] initWithMin:-1.1 max:1.1];
SCINumericAxis3D *yAxis = [SCINumericAxis3D new];
yAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.2 max:0.2];
yAxis.visibleRange = [[SCIDoubleRange alloc] initWithMin:-1.1 max:1.1];
SCINumericAxis3D *zAxis = [SCINumericAxis3D new];
zAxis.growBy = [[SCIDoubleRange alloc] initWithMin:0.2 max:0.2];
zAxis.visibleRange = [[SCIDoubleRange alloc] initWithMin:-1.1 max:1.1];
SCIXyzDataSeries3D *ds = [[SCIXyzDataSeries3D alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double zType:SCIDataType_Double];
for (int i = 0; i < 500; ++i) {
double m1 = SCDDataManager.randomBool ? -1.0 : 1.0;
double m2 = SCDDataManager.randomBool ? -1.0 : 1.0;
double x1 = SCDRandomUtil.nextDouble * m1;
double x2 = SCDRandomUtil.nextDouble * m2;
double temp = 1.0 - x1 * x1 - x2 * x2;
double x = 2.0 * x1 * sqrt(temp);
double y = 2.0 * x2 * sqrt(temp);
double z = 1.0 - 2.0 * (x1 * x1 + x2 * x2);
[ds appendX:@(x) y:@(y) z:@(z)];
}
SCISpherePointMarker3D *pointMarker = [SCISpherePointMarker3D new];
pointMarker.fillColor = 0x88FFFFFF;
pointMarker.size = 7.f;
SCIScatterRenderableSeries3D *rSeries = [SCIScatterRenderableSeries3D new];
rSeries.dataSeries = ds;
rSeries.pointMarker = pointMarker;
rSeries.seriesInfoProvider = [CustomSeriesInfo3DProvider new];
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];
}];
}
@end
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2019. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// CustomSeriesTooltip3DChartView.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.
//******************************************************************************
import SciChart.Protected.SCISeriesTooltip3DBase
import SciChart.Protected.SCISeriesInfo3DProviderBase
private class CustomSeriesInfo3DProvider: SCIDefaultXyzSeriesInfo3DProvider {
private class CustomXyzSerieesTooltip3D: SCIXyzSeriesTooltip3D {
override func internalUpdate(_ seriesInfo: SCISeriesInfo3D) {
var tootlipText = "This is Custom Tooltip \n"
tootlipText += "Vertex id: \((seriesInfo as? SCIXyzSeriesInfo3D)?.vertexId ?? 0)\n"
tootlipText += "X: \(seriesInfo.formattedXValue()?.rawString ?? "-")\n"
tootlipText += "Y: \(seriesInfo.formattedYValue()?.rawString ?? "-")\n"
tootlipText += "Z: \(seriesInfo.formattedZValue()?.rawString ?? "-")"
text = tootlipText
setSeriesColor(seriesInfo.seriesColor.colorARGBCode())
}
}
override func getSeriesTooltipInternal(seriesInfo: SCISeriesInfo3D, modifierType: AnyClass) -> ISCISeriesTooltip3D {
if modifierType == SCITooltipModifier3D.self {
return CustomXyzSerieesTooltip3D(seriesInfo: seriesInfo)
} else {
return super.getSeriesTooltipInternal(seriesInfo: seriesInfo, modifierType: modifierType)
}
}
}
class CustomSeriesTooltip3DChartView: 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.visibleRange = SCIDoubleRange(min: -1.1, max: 1.1)
let yAxis = SCINumericAxis3D()
yAxis.growBy = SCIDoubleRange(min: 0.2, max: 0.2)
yAxis.visibleRange = SCIDoubleRange(min: -1.1, max: 1.1)
let zAxis = SCINumericAxis3D()
zAxis.growBy = SCIDoubleRange(min: 0.2, max: 0.2)
zAxis.visibleRange = SCIDoubleRange(min: -1.1, max: 1.1)
let dataSeries = SCIXyzDataSeries3D(xType: .double, yType: .double, zType: .double)
for _ in 0 ..< 500 {
let m1: Double = SCDDataManager.randomBool() == true ? -1.0 : 1.0
let m2: Double = SCDDataManager.randomBool() == true ? -1.0 : 1.0
let x1 = SCDRandomUtil.nextDouble() * m1
let x2 = SCDRandomUtil.nextDouble() * m2
let temp = 1.0 - x1 * x1 - x2 * x2
let x = 2.0 * x1 * sqrt(temp)
let y = 2.0 * x2 * sqrt(temp)
let z = 1.0 - 2.0 * (x1 * x1 + x2 * x2)
dataSeries.append(x: x, y: y, z: z)
}
let pointMarker = SCISpherePointMarker3D()
pointMarker.size = 7.0
pointMarker.fillColor = 0x88FFFFFF
let rSeries = SCIScatterRenderableSeries3D()
rSeries.dataSeries = dataSeries
rSeries.pointMarker = pointMarker
rSeries.seriesInfoProvider = CustomSeriesInfo3DProvider()
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))
}
}
}