SciChart v3.0 is the latest major release of SciChart - High Performance Realtime Charts framework for iOS.
This guide is provided to ease the transition of existing applications using SciChart v2.5 to the latest APIs, as well as explain the design and structure of new and updated functionality.
In version 3.x iOS API was fully updated to improve flexibility, swift compatibility and become consistent with other platforms.
Because of this, almost all the API has been modified in some way. There’s no possibility to document every single change, so we’re going to attempt to identify the most commonly used parts of SciChart and describe what have been changed there.
Type naming changes
To keep code cleaner and simpler we’ve got rid of convention to end all the protocol names with a “Protocol” suffix and use “I” prefix instead, e.g.:
So in case if, in you SciChart v2 depended code you see the errors like this:
- No type or protocol named 'SCIAxis2DProtocol'
- Cannot find protocol declaration for 'SCIChartSurfaceProtocol'
- No type or protocol named 'SCIRenderableSeriesProtocol'
- Unknown receiver 'SCIBubbleRenderableSeries'; did you mean 'SCIFastBubbleRenderableSeries'?
you’ll need just update a corresponding type name according to a new convention.
Removed SCIGenericType
As Objective-C doesn’t have generics and hence in previous version of SciChart we used to box all the native types into SCIGenericType, which caused code to become inaccurate and dirty. In version 3.x we enriched our API to get rid of SCIGenericType. Some of generic APIs expect object conforming ISCIComparable protocol,
others just extended to work with primitive types directly.
NOTE: SciChart API has extensions for NSNumber and NSDate types, adding conformance to ISCIComparable.
Also SCIArrayController class (which was fully based on the SCIGenericType) has been removed and data structures conforming to ISCIValues were introduced instead.
These changes heavily affected the DataSeries API, so now the preferred way to modify your chart’s data - is using methods based on ISCIValues under the hood.
So if you see the following errors in your SciChart v2 depended code:
- Unknown type name 'SCIGenericType'
- Unknown type name 'SCIArrayController'
- Expected a type 'SCIArrayController'
- Expected a type 'SCIGenericType'
- No visible @interface for 'SCIXyzDataSeries' declares the selector 'initWithXType:YType:ZType:'
- No visible @interface for 'SCIDoubleRange' declares the selector 'initWithMin:Max:'
- Implicit conversion of 'int' to 'id<ISCIComparable>' is disallowed with ARC
Just use ISCIComparable conforming types instead of SCIGenericType, ISCIValues instead of SCIArrayController and remove SCIGenericWrapper.swift from your Swift project.
In v3.x we introduced ISCIAssetManager2D protocol, which is responsible for creating all the engine-specific drawing assets (pen, brushes, sprites, textures etc.).
So in your SciChart v2 depended code, you might see errors like:
- No visible @interface for 'SCISolidPenStyle' declares the selector 'initWithColorCode:withThickness:'
- No visible @interface for 'SCIRadialGradientBrushStyle' declares the selector 'initWithColorCodeStart:finish:'
- No visible @interface for 'SCILinearGradientBrushStyle' declares the selector 'initWithColorCodeStart:finish:direction:'
// SciChart v2.x
SCISolidPenStyle *strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xFF4282B4 withThickness:1.0];
SCILinearGradientBrushStyle *brushStyle = [[SCILinearGradientBrushStyle alloc] initWithColorCodeStart:0xFFfc9930 finish:0xFFd17f28 direction:SCILinearGradientDirection_Vertical];
id<SCIPen2DProtocol> pen = [renderContext createPenFromStyle:strokeStyle];
id<SCIPen2DProtocol> brush = [renderContext createBrushFromStyle:brushStyle];
// SciChart v3.x
// ISCIAssetManager2D instance is passed to each drawing method,
// so if you override drawing code - you never create assetManager instance on your own
SCISolidPenStyle *strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:0xFF4282B4 withThickness:1.0];
SCILinearGradientBrushStyle *brushStyle = [[SCILinearGradientBrushStyle alloc] initWithStart:CGPointMake(0.5, 0.0) end:CGPointMake(0.5, 1.0) colorValues:colorValues stopValues:stopValues];
id<ISCIPen2D> pen = [assetManager penWithStyle:strokeStyle andOpacity:opacity];
id<ISCIBrush2D> brush = [assetManager brushWithStyle:brushStyle];
// SciChart v2.x
let strokeStyle = SCISolidPenStyle(colorCode: 0xFF4282B4, withThickness: 1.0)
let brushStyle = SCILinearGradientBrushStyle(colorCodeStart: 0xFFa9d34f, finish: 0xFF93b944, direction: .vertical)
let pen = renderContext.createPen(fromStyle: strokeStyle)
let brush = renderContext.createBrush(fromStyle: strokeStyle)
// SciChart v3.x
// ISCIAssetManager2D instance is passed to each drawing method,
// so if you override drawing code - you never create assetManager instance on your own
let strokeStyle = SCISolidPenStyle(colorCode: 0xFF4282B4, withThickness: 1.0)
let brushStyle = SCILinearGradientBrushStyle(start: CGPoint(x: 0.5, y: 0.0), end: CGPoint(x: 0.5, y: 1.0), startColorCode: 0xAAFF8D42, endColorCode: 0x88090E11)
let pen = assetManager.pen(withStyle: strokeStyle)
let brush = assetManager.brush(withStyle: brushStyle)
This will affect your code if you have implemented custom drawing of some SciChart visual primitives.
For example, now customization of renderable series drawing you’ll need to override the following method:
To become more flexible, and have better integration into SciChart run loop - Animation API has been completely re-designed and re-written.
In SciChart v3.x we introduced SCIAnimations utility, which provides an interface to create basic animations for renderable series.
So in your SciChart v2 depended code, you might see errors like:
To get more details about existing easing functions and animation types, please check Animation API guide.
Annotations API
All the annotations in SciChart v3.x conforms to the ISCIAnnotation protocol and inherits SCIAnnotationBase class.
To get more info about existing annotation types and common functionality of the SCIAnnotationBase please check the documentation for Annotations API.
The most prominent changes to the Annotations API are the following:
As the SCIGenericType was removed, now annotation coordinates became ISCIComparable.
AnnotationStyle classes (e.g SCILineAnnotationStyle, SCITextAnnotationStyle) were removed, their properties either moved to corresponding annotation class, or to the SCIAnnotationBase.
So in your SciChart v2 depended code, you might see errors like:
- Property 'style' not found on object of type 'SCITextAnnotation *'
- Property 'style' not found on object of type 'SCIHorizontalLineAnnotation *'
// SciChart v2.x
var horizontalLine1 = new SCIHorizontalLineAnnotation
{
X1Value = 5.0,
Y1Value = 3.2,
HorizontalAlignment = SCIHorizontalLineAnnotationAlignment.Right,
Style = new SCILineAnnotationStyle { LinePen = new SCISolidPenStyle(UIColor.Orange, 2f) },
};
horizontalLine1.AddLabel(new SCILineAnnotationLabel
{
Text = “Right Aligned, with text on left”,
Style = { LabelPlacement = SCILabelPlacement.TopLeft }
});
// SciChart v3.x
var horizontalLine1 = new SCIHorizontalLineAnnotation
{
X1Value = 5.0,
Y1Value = 3.2,
HorizontalAlignment = SCIAlignment.Right,
Stroke = new SCISolidPenStyle(UIColor.Orange, 2),
};
horizontalLine1.AnnotationLabels.Add(new SCIAnnotationLabel
{
LabelPlacement = SCILabelPlacement.TopLeft,
Text = “Right Aligned, with text on left”,
});
Chart Modifiers API
In SciChart v3.x Chart Modifiers API was deeply refactored, became more flexible, easy to use and have now more clear customization points.
To get more information about all available chart modifier types, please visit the Chart Modifier APIs article.
Breaking changes of the Chart Modifiers API, which might impact your code are listed below:
ModifierStyle’s objects have been removed and their properties moved to corresponding modifier classes (The same way like with annotations).
// Override this method to make modifier work with custom gesture recognizer-(UIGestureRecognizer*)createGestureRecognizer;// Override this method to handle gesture recognizers action-(void)internalHandleGesture:(UIPinchGestureRecognizer*)gestureRecognizer
So in your SciChart v2 depended code, you might see errors like:
- Property 'style' not found on object of type 'SCICursorModifier *'
- Cannot find interface declaration for 'SCIGestureModifier', superclass of 'CustomModifier'; did you mean 'SCIGestureModifierBase'?
- Interface type 'SCIHitTestInfo' cannot be passed by value
- Property 'match' not found on object of type 'SCIHitTestInfo *'
Here is an example of SCIRolloverModifier customization (the rest of listed modifiers have quite the same customization logic):
Also in SciChart v3 we improved a mechanism of syncing modifiers, of multiple surfaces. As a result,SCIMultiSurfaceModifier, SCIAxisAreaSizeSynchronization and SCIAxisRangeSynchronization classes got removed.
As the result, in your SciChart v2 depended code, you might see errors like:
- Unknown type name 'SCIAxisRangeSynchronization'
- Unknown type name 'SCIMultiSurfaceModifier'
So, now to sync ranges of two axises (from different surfaces) you’ll need just assign both of them the same instance of
visibleRange. And to synchronize modifiers - you’ll need just create an SCICharModifierGroup with the same event tag for both surfaces, and put in this group all the modifiers you want to be synchronized: