Let’s see a simple example of using sweep animation on our Line Series:
// declare FastLineRenderableSeries to animate
SCIFastLineRenderableSeries *rSeries = [SCIFastLineRenderableSeries new];
// Animate Line Series with Sweep Transformation
[SCIAnimations sweepSeries:rSeries duration:3.0 andEasingFunction:[SCICubicEase new]];
// declare FastLineRenderableSeries to animate
let rSeries = SCIFastLineRenderableSeries()
// Animate Line Series with Sweep Transformation
SCIAnimations.sweep(rSeries, duration: 3.0, easingFunction: SCICubicEase())
// declare FastLineRenderableSeries to animate
var rSeries = new SCIFastLineRenderableSeries();
// Animate Line Series with Sweep Transformation
SCIAnimations.SweepSeries(rSeries, 3, new SCICubicEase());
SCIAnimations methods accept few key parameters, such as duration, delay and easingFunction. The first two are pretty self-explanatory, but the last one - easingFunction - which is ISCIEasingFunction, allows to transform animation progress before applying transformation. There are a bunch of easing function provided out of the box in SciChart (which are all based on SCIEasingFunctionBase):
SCIAnimations.SweepSeries(rSeries, 3, new SCICubicEase());
NOTE: The Sweep animation is implemented utilizing the Sweep Transformation under the hood and available only for continuous series (e.g. Line, Mountain, Band etc…), where it’s possible to interpolate points to have smooth animation.
SCIAnimations.TranslateYSeries(rSeries, -500, 3, new SCICubicEase());
NOTE: The Translate-Y animation is implemented utilizing the Translate Transformation under the hood.
Transformation API
The Transformation API is based on ISCIRenderPassDataTransformation protocol which allows to define different transformations for ISCIRenderableSeries which we apply during animation. When we start SCIValueAnimator created by SCIAnimations - it animates the Progress of transformation from 0 (beginning of animation) to 1 (end of animation).
There are several transformations provided out of the box which allow to animate different types of series:
NOTE:Translate-X and Translate-Y animations are implemented based on this transformation.
Composite Transformation
You might want to combine effects of several transformations at the same time without rewriting those into complex transformation. The SCICompositeTransformation is in SciChart to do just that. It allows to aggregate effects into one transformation (e.g. wave and translate-x)
// declare Candlestick Series to animate
SCIFastCandlestickRenderableSeries *rSeries = [SCIFastCandlestickRenderableSeries new];
// Create transformations and make a Composite one out of them
SCIWaveOhlcTransformation *wave = [[SCIWaveOhlcTransformation alloc] initWithRenderPassDataType:SCIOhlcRenderPassData.class zeroLine:0 andDurationOfStep:0.5];
SCITranslateXTransformation *translateX = [[SCITranslateXTransformation alloc] initWithRenderPassDataType:SCIOhlcRenderPassData.class andOffset:-300];
SCICompositeTransformation *composite = [[SCICompositeTransformation alloc] initWithTransformations:@[wave, translateX]];
// Animate Candlestick Series with Composite Transformation
[SCIAnimations animateSeries:rSeries withTransformation:composite duration:3.0 andEasingFunction:[SCICubicEase new]];
// declare Candlestick Series to animate
let rSeries = SCIFastCandlestickRenderableSeries()
// Create transformations and make a Composite one out of them
let wave = SCIWaveOhlcTransformation(renderPassDataType: SCIOhlcRenderPassData.self, zeroLine: 0, andDurationOfStep: 0.5)
let translateX = SCITranslateXTransformation(renderPassDataType: SCIOhlcRenderPassData.self, andOffset: -300)
let composite = SCICompositeTransformation(transformations: [wave, translateX])
// Animate Candlestick Series with Composite Transformation
SCIAnimations.animate(rSeries, with: composite, duration: 3.0, andEasingFunction: SCICubicEase())
// declare Candlestick Series to animate
var rSeries = new SCIFastCandlestickRenderableSeries();
// Create transformations and make a Composite one out of them
var wave = new SCIWaveOhlcTransformation(typeof(SCIOhlcRenderPassData).ToClass(), 0, 0.5f);
var translateX = new SCITranslateXTransformation(typeof(SCIOhlcRenderPassData).ToClass(), -300);
var composite = new SCICompositeTransformation(new IISCIRenderPassDataTransformation[] { wave, translateX });
// Animate Candlestick Series with Composite Transformation
SCIAnimations.AnimateSeries(rSeries, composite, 3.0, new SCICubicEase());
which results in the following:
NOTE: You can create animation for your series with any transformation you want, as we just did in the example above. There are appropriate methods for that in SCIAnimations:
To create custom animation we need to create a class which implements ISCIRenderPassDataTransformation protocol. Inside we need to add code which modifies the render pass data of the RenderableSeries which we need to animate. For example, we’ll try to animate line series and create expand effect which moves points from some predefined origin point.
var customTransformation = new CustomXyTransformation(new CGPoint(150, 300));
SCIAnimations.AnimateSeries(rSeries, customTransformation, 1.5, new SCIQuadraticEase());