2010-05-20 31 views
1

我想绘制一个酒吧系列以“反弹”时,我假设BounceEase TransitionEasingFunction会做到这一点,但线条只是淡入,我已经将xaml和代码贴在下面,没有人知道我在哪里出了问题或者是比我更复杂的,虽然,我是相当新的Silverlight的BounceEase和silverlight 4 BarSeries

XAML

<Grid x:Name="LayoutRoot" Background="White"> 
    <chartingToolkit:Chart x:Name="MyChart"> 
     <chartingToolkit:BarSeries Title="Sales" ItemsSource="{Binding}" IndependentValuePath="Name" DependentValuePath="Value" AnimationSequence="FirstToLast" TransitionDuration="00:00:3"> 
      <chartingToolkit:BarSeries.TransitionEasingFunction> 
       <BounceEase EasingMode="EaseInOut" Bounciness="5" /> 
      </chartingToolkit:BarSeries.TransitionEasingFunction> 
      <chartingToolkit:BarSeries.DataPointStyle> 
       <Style TargetType="Control"> 
        <Setter Property="Background" Value="Red"/> 
       </Style> 
      </chartingToolkit:BarSeries.DataPointStyle> 
     </chartingToolkit:BarSeries> 
     <chartingToolkit:Chart.Axes> 
      <chartingToolkit:LinearAxis Title="Types owned" Orientation="X" Minimum="0" Maximum="300" 
       Interval="10" ShowGridLines="True" FontStyle='Italic'/> 
     </chartingToolkit:Chart.Axes> 
    </chartingToolkit:Chart> 

</Grid> 

代码背后

public class MyClass : DependencyObject 
    { 
     public string Name { get; set; } 
     public Double Value { 
      get { return (Double)GetValue(myValueProperty); } 
      set{SetValue(myValueProperty,value);} 
     } 
     public static readonly DependencyProperty myValueProperty = 
      DependencyProperty.Register("Value", typeof(Double), typeof(MyClass), null); 
    } 

public MainPage() 
     { 
      InitializeComponent(); 
      //Get the data 
      IList<MyClass> l = this.GetData(); 
      //Get a reference to the SL Chart 

     MyChart.DataContext = l.OrderBy(e => e.Value); 
     //Find the highest number and round it up to the next digit 
     DispatcherTimer myDispatcherTimer = new DispatcherTimer(); 
     myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 5, 0); // 100 Milliseconds 
     myDispatcherTimer.Tick += new EventHandler(Each_Tick); 
     myDispatcherTimer.Start(); 

    } 
    public void Each_Tick(object o, EventArgs sender) 
    { 
     ((BarSeries)MyChart.Series[0]).DataContext = GetData(); 
    } 

    private IList<MyClass> GetData() 
    { 
     Random random = new Random(); 

     return new List<MyClass>() 
     { 
      new MyClass() {Name="Bob Zero",Value=(random.NextDouble() * 100.0)}, 
      new MyClass() {Name="Bob One",Value=(random.NextDouble() * 100.0)}, 
       new MyClass() {Name="Bob Two",Value=(random.NextDouble() * 100.0)}, 
       new MyClass() {Name="Bob Three",Value=(random.NextDouble() * 100.0)} 
     }; 
    } 

回答

0

名称BounceEas e指的是在动画时间动画的值是如何变化的。 BounceEase根据您可能想像的球弹跳而变化。文档中的图形描述了它。

关键是最终动画只是​​改变一个值,他们并不真正了解变化值的视觉效果。在这种情况下,动画的值是DataPoint不透明度。因此,随着反弹的缓解,它似乎淡入一点,然后淡出,然后淡化一小块,直到它完全淡入。

这将需要相当多的工作,为DataPoint创建一个新模板得到你以后的效果。

+0

谢谢,这个解释完美,也解释了我看到的一些例子。它非常有意义 – Pharabus 2010-05-20 23:01:23