基础介绍。XAML动画(三)
之前我们介绍了两种基础的动画,本文就接着来介绍Rotation动画。
创建Rotation动画
Rotation动画和scaling动画类似-他们都仅仅使用一个RotateTransform而不是ScaleTransform。而且类似scaling动画你可以自定义原点(RenderTransformOrigin),同样也是easing功能。
代码参考:
<Style TargetType="c1:PlotElement" x:Key="styleRotate"> <Setter Property="RenderTransform"> <Setter.Value> <RotateTransform Angle="180" /> </Setter.Value> </Setter> <Setter Property="RenderTransformOrigin" Value="0.5, 0.5" /> </Style> <Storyboard x:Key="sbRotate"> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).Angle" Duration="00:00:01" To="1" c1:PlotElementAnimation.IndexDelay="0.5"> <DoubleAnimation.EasingFunction> <BackEase EasingMode="EaseIn" Amplitude="5" /> </DoubleAnimation.EasingFunction> </DoubleAnimation> </Storyboard>
Index Delay
如果你是应用任何之前提到的例子,需要注意所有的plot元素动画。由于附属与IndexDelay属性。
它允许你在每个点之间设置一个延迟时间。它会创建escalating动画效果,这对于Column,bar,pie和scatter图表都是可用的。(它对Area或是Line图表没有实际效果)。
例如,我们来再次看看scaling动画,这次我们设置IndexDelay属性给每一个动画对象,去创建我们的延迟。
代码参考:
<Style TargetType="c1:PlotElement" x:Key="styleScale"> <Setter Property="RenderTransform"> <Setter.Value> <ScaleTransform ScaleX="0" ScaleY="0" /> </Setter.Value> </Setter> <Setter Property="RenderTransformOrigin" Value="0.5, 0.5" /> </Style> <Storyboard x:Key="sbScale"> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).ScaleX" Duration="00:00:01" From="0" To="1" c1:PlotElementAnimation.IndexDelay="0.5"> <DoubleAnimation.EasingFunction> <CubicEase EasingMode="EaseInOut" /> </DoubleAnimation.EasingFunction> </DoubleAnimation> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).ScaleY" Duration="00:00:00" From="0" To="1"> <DoubleAnimation.EasingFunction> <CubicEase EasingMode="EaseInOut" /> </DoubleAnimation.EasingFunction> </DoubleAnimation> </Storyboard>
本文的介绍到此结束,本文所介绍的示例代码如下所示:
ChartAnimation_Rotate.zip (316.17 kb)
下面还会介绍使用TransformGroup.
Chart的在线英文产品文档地址:
http://helpcentral.componentone.com/nethelp/c1wpfchart/#!Documents/componentonechartforwpf.htm
如果你对C1Chart感兴趣,请到我们的官网下载最新版本:/developer/componentone-winform/controls/chart
如果你有疑问,可以到GCDN论坛获得技术支持:http://gcdn.grapecity.com.cn/showforum-68.html
《C1Chart for WPF初级教程》系列文章: