Hi everyone,

My name is Velin Angelov. I am a member of Telerik's Charting team and here I am going to write about a feature of the RadChart for WPF which you might find useful while having fun with it.

RadChart for WPF was shipped with the 2008.Q3 release and one feature all of the charts have in common is being animated.

From this point on there are three options:

  1. You are absolutely happy (as you probably will) with the default animation settings provided by RadChart. In this case you simply keep on coding.
  2. You totally disagree with the way RadChart is animated and you have much better idea how this should be done. In this case you have to get your hands dirty with overriding the default chart item template and turn your fabulous idea into xaml.
  3. You think that the default behavior is quite acceptable… Only if you were able to slightly adjust these timings… And you can. RadChart now exposes the AnimationSettings class which will do this for you almost for free. The only thing you should do is to set your custom animation settings either to RadChart or to the series definition itself.

 

If you think the third option is exactly what you need to do, more explanation is coming up. Here is a brief description of AnimationSettings’ class properties:

  • ItemAnimationDuration - setting this property will cause RadChart to animate each ChartItem in exactly the time specified. Defaults to 1 second. 
  • TotalAnimationDuration - setting this property will cause RadChart to animate each DataSeries in exactly the time specified. Defaults to 0 seconds.
  • ItemDelay - setting this property will cause RadChart to animate each ChartItem with delay based on its index in exactly the time specified. Defaults to 1 second.
  • DefaultSeriesDelay - setting this property will cause RadChart to animate each DataSeries with delay based on its index in exactly the time specified. Defaults to 0.2 seconds.

The first thing you should be aware is that the default animation behavior for given DataSeries will be overridden (and lost) once you provide your own animation settings. You can do it like this:

Or like this:

The difference between these two approaches is that setting the animation settings at RadChart affects all the DataSeries hosted within, while setting the animation settings at the DataSeries affects only the way this series is animated. Having set animation settings at both places the one at the DataSeries will be used.

Another thing worth mentioning is the priority of the animation setting properties. You cannot have all of them set at the same time. In other words whenever the TotalAnimationDuration property is set it will take precedence over the ItemDelay property resulting on ItemDelay being calculated in runtime based on the values of TotalAnimationDuration and ItemAnimationDuration properties. So if you plan to adjust your animation on ItemAnimationDuration and ItemDelay basis – don’t touch TotalAnimationDuration or set it to its default value – TimeSpan.Zero.

 

Hope this helps. 


Related Posts

Comments

Comments are disabled in preview mode.