Animation Style Type Parameters
One of the best things about FusionCharts is the animated charting sequences that users get to relish. By default, FusionCharts animates only the data plot (columns, bars, lines etc.). However, FusionCharts v3 does not limit your imaginations just there. Using the Animation Style Type, you can virtually animate each and every object on the chart. You can define custom animations and apply them to various objects of the chart. Each chart object has a list of supported animation properties that can be set through Animation Style Type. Before we get to the parameters supported by the animation style type, let's quickly glance through the properties of chart objects that we can animate using Animation Style Type. The animation style type helps you animate the following properties of chart objects:
Property | Description
_x | Helps animate the x position of the given chart object
_y | Helps animate the y position of the given chart object.
_xScale | Using this property, you can animate the x-scale (horizontal scale) of the given chart object
_yScale | Like xScale, this animates the y-scale.
_alpha | Helps alpha transition (transparency fading) animation effect
_rotation | Helps you animate the pies and doughnuts in circular motion
Not all parameters can be applied to all chart objects. For example, text fields cannot be x-scaled or y-scaled nor does the rotation effect apply to them. Similarly, the horizontal div lines do not support y-scaling and x-shifting. The list of animation parameters for each chart object is given in the Chart Specification sheet of the respective chart. Multiple animations in combination or multiple animations in sequence can also be applied to any chart object. For example, you can opt to y-scale and alpha-fade the data plot (combination animation) or you might go for x-scale first and then y-scale (sequential animation). Let's now get to the attributes that Animation Style Type exposes to help us control the functionalities:
Attribute | Description
param | This attribute lets you specify the property of chart object which you want to animate e.g., _x, _y, _xscale etc
start | The start value of animation e.g., if you're animating the data plot for fade in alpha effect, the start value of alpha would be 0
Duration | Using this, you can control the duration of animation in seconds
Easing | This attribute lets you specify the pattern of animation easing. Valid values are "elastic", "bounce", "regular", "strong" or "none".
For the Animation Style Type, except Easing, all the above attributes are mandatory Before getting to detailed explanations, let's quickly cruise through a quick animation sample. Let's try and animate our canvas so that it scales up after the chart is loaded. To do so, we first need to define our custom style. Since scaling up involves simultaneous increment of both _xScale and _yScale, we'll now need to define two animation styles and then apply them to Canvas object. The style definition goes as under:
<styles> <definition> <style name='MyXScaleAnim' type='ANIMATION' duration='1' start='0' param="_xscale" /> <style name='MyYScaleAnim' type='ANIMATION' duration='1' start='0' param="_yscale" /> </definition> ... More XML Here .... </styles>
In the above code, we name the two styles as MyXScaleAnim and MyYScaleAnim with their param (animation parameter) as _xscale and _yscale respectively. We set start value as 0, we want the canvas to scale up from 0 to 100 (remember that scales are always from 0-100 in FusionCharts). We also specify the duration as 1 for the animation sequence. To apply this animation style to canvas, the following code is used:
<styles> ... More XML Here .... <application> <apply toObject='Canvas' styles='MyXScaleAnim,MyYScaleAnim' /> </application> </styles>
If you run the above code against a single series axis chart, you'll see that the canvas scales up from 0 size to full size, before the data is animated and rendered. Bingo! Exactly what we needed! Let's move on to the attributes in details now.
param attribute
The param attribute specifies the property of chart object, which is to be animated. As earlier discussed, it can take one of the following values, depending on the chart object: _x _y _xScale _yScale _alpha _rotation We reiterate that not all chart objects support all the above properties. Please refer to the Chart Specification Sheet for the given chart to get the list of supporter animation parameters for each chart object.
Setting the start position of animation object
In our above example, where we were scaling the canvas from 0 to 100, we had set the start value of animation to 0, as we want the canvas to scale from 0 to 100. You always need to set a start value for any animation style. The end value is decided by FusionCharts based on the chart object and animation parameter. For example, if you want to animate the y position of div lines from 0 to their final position (which is within the canvas), you need to set start position to 0. But since you do not know the end position of individual div line, it's automatically set by FusionCharts. Similarly, if you want to animate the div lines Y position for a chart, whose height is 500 pixels, from bottom to the respective final position, you'll need to set start position as 500. The end position again will be decided by FusionCharts.
Macros in start values
Often, you might want to specify the start x/y position for the animation as the start/center/end position of the canvas or chart. For example, if you want to animate the y property of div lines from canvas top to their respective final position, you'll need to experiment with a lot of Y values before you can finally get the start Y position of canvas. This is because the canvas start position is dynamically calculated at run-time and it depends on a lot of factors like captions, sub captions, chart padding, margins etc. FusionCharts v3 introduces Macros to bail you out of this trouble. Macros are pre-defined variables which assume values at run time. For example, $canvasStartY represents the start Y position of the canvas, and it assumes a value at run-time only. So, if you need to animate your div lines' Y position from canvas start Y to their final actual positions, all you need to do is: <style name='DivYAnim' type='ANIMATION' duration='1' start='$canvasStartY' param="_y" /> FusionCharts, at run-time, will automatically calculate and assign the value for this macro and you'll see the animation sequence starting from start Y Position of canvas. So, now even if you resize the chart or opt to show/hide captions or change margins, you never need to keep a tab on the y position of canvas. FusionCharts does that for you. FusionCharts v3 supports the following Macro values for Animation Style Type:
$chartStartX | Chart Start X Position. It's 0 if you're loading the chart in an HTML page. However, if you're loading the chart in another Flash movie, it will take the given X position
$chartStartY | Chart Start Y Position. It's 0 if you're loading the chart in an HTML page. However, if you're loading the chart in another Flash movie, it will take the given Y position.
$chartWidth | Width of the chart
$chartHeight | Height of the chart
$chartEndX | End X Position of the chart. Same as width of chart if you're loading the chart in an HTML page
$chartEndY | End Y Position of the chart. Same as height of chart if you're loading the chart in an HTML page.
$chartCenterX | Center X Position of the chart
$chartCenterY | Center Y Position of the chart.
$canvasStartX | Canvas Start X Position (from left) i.e., x co-ordinate of left side of the canvas
$canvasStartY | Canvas Start Y Position (from top) i.e., y co-ordinate of the top of canvas
$canvasWidth | Width of canvas
$canvasHeight | Height of canvas
$canvasEndX | End X Position of Canvas i.e., x co-ordinate of right side of canvas
$canvasEndY | End Y Position of Canvas i.e., y co-ordinate of bottom of canvas
$canvasCenterX | Center X Position of canvas
$canvasCenterY | Center Y Position of canvas
Macro names are case-sensitive. As such, you need to make sure that you're providing the macro names in proper case i.e., $canvasstarty won't work and it will log an error in debug window. You'll need to correctly specify it as $canvasStartY.
More Examples using Macros: <style name='LabelsAnim' type='ANIMATION' duration='1' start='$canvasCenterX' param="_x" /> <style name='YValuesAnim' type='ANIMATION' duration='1' start='$canvasCenterY' param="_y" />
Creating Macro Expressions
You can also add numeric (integer) values to pre-defined macros to offset the animation when using macros. For example, if you wanted to animate the div lines from 10 pixels above canvas starting Y position, you could use: <style name='DivYAnim' type='ANIMATION' duration='1' start='$canvasStartY-10' param="_y" /> Or, if you wanted to animate from 10 pixels below canvas start position, you could use: <style name='DivYAnim' type='ANIMATION' duration='1' start='$canvasStartY+10' param="_y" /> Currently, FusionCharts allows only + (addition) and - (substraction) operation in Macro expressions.
Specifying the easing for animation
Easing refers to gradual acceleration or deceleration during an animation. For example, a chart object might gradually increase its speed near the beginning of an animation, but slow down right at the end of the animation before it arrives at a full stop. There are many different equations for the acceleration and deceleration, which change the easing animation accordingly. Easing helps your animations appear more realistic.
FusionCharts v3 supports the following easing methods:
Methods | Description
Elastic | Adds an elastic effect that falls outside the transition range at one or both ends. The amount of elasticity is unaffected by the duration
Bounce | Adds a bouncing effect within the transition range at one or both ends. The number of bounces relates to the duration—longer durations produce more bounces
Strong | Adds slower movement at one or both ends. This effect is similar to Regular easing, but it's more pronounced
Regular | Adds slower movement at one or both ends. This feature enables you to add a speeding-up effect, a slowing-down effect, or both.
None | Adds an equal movement from start to end without effects, slowing, or speeding up. This transition is also referred to as a linear transition.
For any of the above easing method, FusionCharts provides the easing effect at the end of the transition. For example, if you animate the columns from 0 _yscale to 100 _yscale, you'll see that the columns animated very fast in the start (they grow up very soon) but the animation at the end part is slow. You can use any of the above easing methods for any animation style that you define.