我想在绘图时让条形图系列“反弹”,我假设BounceEase TransitionEasingFunction会这样做但是线条刚刚淡入,我已经发布了下面的xaml和代码,有没有人知道我去了哪里错误或者比我更复杂,我对银光来说还是个新手
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 :(得分:0)
名称BounceEase指的是动画值在动画时间内的变化方式。 BounceEase可以像你想象的那样改变球的弹跳值。文档中的图形描述了它。
关键点在于,最终动画只是改变了一个值,他们并不真正理解变量值的视觉效果。在这种情况下,动画的值是DataPoint不透明度。因此,在弹跳轻松的情况下,它会逐渐消失,然后消失,然后逐渐消失,等等,直到它完全消失为止。
为DataPoint创建新模板以获得您想要的效果需要花费更多的工作。