本文整理汇总了C#中LineSeries.GetAnimatablePoints方法的典型用法代码示例。如果您正苦于以下问题:C# LineSeries.GetAnimatablePoints方法的具体用法?C# LineSeries.GetAnimatablePoints怎么用?C# LineSeries.GetAnimatablePoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LineSeries
的用法示例。
在下文中一共展示了LineSeries.GetAnimatablePoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnimateSeriesAsync
public static async Task AnimateSeriesAsync(
this PlotModel plotModel,
LineSeries series,
AnimationSettings settings)
{
var points = series.GetAnimatablePoints();
if (points.Count == 0)
{
return;
}
var duration = settings.Duration;
if (duration == default(TimeSpan))
{
duration = TimeSpan.FromMilliseconds(DefaultAnimationDuration);
}
var easingFunction = settings.EasingFunction;
if (easingFunction == null)
{
easingFunction = DefaultEasingFunction;
}
var animationFrameDurationInMs = (int)settings.FrameDuration.TotalMilliseconds;
var minimumValue = settings.MinimumValue;
var animationFrames = new List<AnimationFrame>();
var horizontalDuration = duration.TotalMilliseconds / 100 * settings.HorizontalPercentage;
var verticalDuration = duration.TotalMilliseconds / 100 * settings.VerticalPercentage;
var animationFrameCount = (int)(duration.TotalMilliseconds / animationFrameDurationInMs);
var animationFrameDuration = TimeSpan.FromMilliseconds(animationFrameDurationInMs);
if (!minimumValue.HasValue)
{
minimumValue = 0d;
var defaultYAxis = plotModel.DefaultYAxis;
if (defaultYAxis != null)
{
if (defaultYAxis.Minimum > 0d)
{
minimumValue = defaultYAxis.Minimum;
}
}
}
var minX = (from point in points orderby point.X select point.X).Min();
var maxX = (from point in points orderby point.X select point.X).Max();
var deltaX = maxX - minX;
for (var i = 0; i < animationFrameCount; i++)
{
var animationFrame = new AnimationFrame
{
Duration = animationFrameDuration
};
var currentTime = animationFrameDurationInMs * i;
var percentage = i * 100d / animationFrameCount;
var horizontalPercentage = currentTime * 100d / horizontalDuration;
if (horizontalPercentage > 100d)
{
horizontalPercentage = 100d;
}
var currentDeltaX = deltaX / 100d * horizontalPercentage;
var currentX = minX + currentDeltaX;
// Get the last visible point. It should not be based on the index (can be really different), but on the X position
// since we want to draw a smooth animation
var lastVisibleHorizontalPoint = 0;
for (int j = 0; j < points.Count; j++)
{
if (points[j].FinalX > currentX)
{
break;
}
lastVisibleHorizontalPoint = j;
}
for (var j = 0; j < points.Count; j++)
{
var point = points[j];
var isVisible = true;
var y = point.FinalY;
var x = point.FinalX;
var nextPointIndex = lastVisibleHorizontalPoint + 1;
if (j > nextPointIndex)
{
isVisible = false;
}
if (j >= nextPointIndex)
//.........这里部分代码省略.........