public override CAAnimation AnimationForSeries(TKChart chart, TKChartSeries series, TKChartSeriesRenderState state, CGRect rect) { double duration = 0.5; List<CAAnimation> animations = new List<CAAnimation> (); for (int i = 0; i<(int)state.Points.Count; i++) { string keyPath = string.Format ("seriesRenderStates.{0}.points.{1}.y", series.Index, i); TKChartVisualPoint point = (TKChartVisualPoint)state.Points.ObjectAtIndex((uint)i); double oldY = rect.Height; double half = oldY + (point.Y - oldY)/2.0; CAKeyFrameAnimation a = (CAKeyFrameAnimation)CAKeyFrameAnimation.GetFromKeyPath(keyPath); a.KeyTimes = new NSNumber[] { new NSNumber (0), new NSNumber (0), new NSNumber (1) }; a.Values = new NSObject[] { new NSNumber (oldY), new NSNumber (half), new NSNumber (point.Y) }; a.Duration = duration; a.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseOut); animations.Add(a); } CAAnimationGroup group = new CAAnimationGroup (); group.Duration = duration; group.Animations = animations.ToArray(); return group; }
public override CAAnimation AnimationForSeries(TKChart chart, TKChartSeries series, TKChartSeriesRenderState state, CGRect rect) { double duration = 0; List<CAAnimation> animations = new List<CAAnimation>(); for (int i = 0; i<(int)state.Points.Count; i++) { string pointKeyPath = state.AnimationKeyPathForPointAtIndex ((uint)i); string keyPath = string.Format("{0}.distanceFromCenter", pointKeyPath); CAKeyFrameAnimation a = CAKeyFrameAnimation.GetFromKeyPath(keyPath); a.Values = new NSNumber[] { new NSNumber(50), new NSNumber(50), new NSNumber(0) }; a.KeyTimes = new NSNumber[] { new NSNumber(0), new NSNumber(i/(i+1.0)), new NSNumber(1) }; a.Duration = 0.3 * (i+1.1); animations.Add(a); keyPath = string.Format("{0}.opacity", pointKeyPath); a = CAKeyFrameAnimation.GetFromKeyPath(keyPath); a.Values = new NSNumber[] { new NSNumber(0), new NSNumber(0), new NSNumber(1) }; a.KeyTimes = new NSNumber[] { new NSNumber(0), new NSNumber(i/(i+1.0)), new NSNumber(1) }; a.Duration = 0.3 * (i+1.1); animations.Add(a); duration = a.Duration; } CAAnimationGroup g = new CAAnimationGroup(); g.Duration = duration; g.Animations = animations.ToArray(); return g; }
public override CAAnimation AnimationForSeries (TKChart chart, TKChartSeries series, TKChartSeriesRenderState state, CGRect rect) { double duration = 0; List<CAAnimation> animations = new List<CAAnimation> (); for (int i = 0; i<(int)state.Points.Count; i++) { TKChartVisualPoint point = (TKChartVisualPoint)state.Points.ObjectAtIndex ((uint)i); if (Grow) { string keyPath = string.Format ("seriesRenderStates.{0}.points.{1}.x", series.Index, i); CABasicAnimation animation = (CABasicAnimation)CABasicAnimation.FromKeyPath(keyPath); animation.Duration = 0.1 *(i + 0.2); animation.From = new NSNumber(0); animation.To = new NSNumber(point.X); animation.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseOut); animations.Add(animation); duration = animation.Duration; } else { string keyPath = string.Format ("seriesRenderStates.{0}.points.{1}.y", series.Index, i); nfloat oldY = rect.Height; if (i > 0) { CAKeyFrameAnimation animation = (CAKeyFrameAnimation)CAKeyFrameAnimation.GetFromKeyPath(keyPath); animation.Duration = 0.1* (i + 1); animation.Values = new NSNumber[] { new NSNumber(oldY), new NSNumber(oldY), new NSNumber(point.Y) }; animation.KeyTimes = new NSNumber[] { new NSNumber(0), new NSNumber(i/(i+1.0)), new NSNumber(1) }; animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); animations.Add (animation); duration = animation.Duration; } else { CABasicAnimation animation = (CABasicAnimation)CABasicAnimation.FromKeyPath(keyPath); animation.From = new NSNumber(oldY); animation.To = new NSNumber(point.Y); animation.Duration = 0.1f; animations.Add(animation); } } } CAAnimationGroup group = new CAAnimationGroup (); group.Duration = duration; group.Animations = animations.ToArray(); return group; }
public override CAAnimation AnimationForSeries(TKChart chart, TKChartSeries series, TKChartSeriesRenderState state, CGRect rect) { double duration = 0; List <CAAnimation> animations = new List <CAAnimation>(); for (int i = 0; i < (int)state.Points.Count; i++) { string pointKeyPath = state.AnimationKeyPathForPointAtIndex((uint)i); string keyPath = string.Format("{0}.distanceFromCenter", pointKeyPath); CAKeyFrameAnimation a = CAKeyFrameAnimation.GetFromKeyPath(keyPath); a.Values = new NSNumber[] { new NSNumber(50), new NSNumber(50), new NSNumber(0) }; a.KeyTimes = new NSNumber[] { new NSNumber(0), new NSNumber(i / (i + 1.0)), new NSNumber(1) }; a.Duration = 0.3 * (i + 1.1); animations.Add(a); keyPath = string.Format("{0}.opacity", pointKeyPath); a = CAKeyFrameAnimation.GetFromKeyPath(keyPath); a.Values = new NSNumber[] { new NSNumber(0), new NSNumber(0), new NSNumber(1) }; a.KeyTimes = new NSNumber[] { new NSNumber(0), new NSNumber(i / (i + 1.0)), new NSNumber(1) }; a.Duration = 0.3 * (i + 1.1); animations.Add(a); duration = a.Duration; } CAAnimationGroup g = new CAAnimationGroup(); g.Duration = duration; g.Animations = animations.ToArray(); return(g); }
public override CAAnimation AnimationForSeries(TKChart chart, TKChartSeries series, TKChartSeriesRenderState state, CGRect rect) { var duration = 0.0; var animations = new List <CAAnimation>(); for (int i = 0; i < (int)state.Points.Count; i++) { var pointKeyPath = state.AnimationKeyPathForPointAtIndex((uint)i); var keyPath = pointKeyPath + ".y"; var point = state.Points.ObjectAtIndex((uint)i) as TKChartVisualPoint; var oldY = rect.Size.Height; if (i > 0) { var animation = new CAKeyFrameAnimation(); animation.KeyPath = keyPath; animation.Duration = (double)(0.1 * i); animation.Values = new NSNumber[] { new NSNumber(oldY), new NSNumber(oldY), new NSNumber(point.Y) }; animation.KeyTimes = new NSNumber[] { new NSNumber(0), new NSNumber(i / (i + 1.0)), new NSNumber(1.0) }; animations.Add(animation); duration = animation.Duration; } else { var animation = new CABasicAnimation(); animation.KeyPath = keyPath; animation.From = new NSNumber(oldY); animation.To = new NSNumber(point.Y); animation.Duration = 0.1; animations.Add(animation); } } var group = new CAAnimationGroup(); group.Duration = duration; group.Animations = animations.ToArray(); return(group); }
public override CAAnimation AnimationForSeries(TKChart chart, TKChartSeries series, TKChartSeriesRenderState state, CGRect rect) { double duration = 0.5; List <CAAnimation> animations = new List <CAAnimation> (); for (int i = 0; i < (int)state.Points.Count; i++) { string keyPath = string.Format("seriesRenderStates.{0}.points.{1}.y", series.Index, i); TKChartVisualPoint point = (TKChartVisualPoint)state.Points.ObjectAtIndex((uint)i); double oldY = rect.Height; double half = oldY + (point.Y - oldY) / 2.0; CAKeyFrameAnimation a = (CAKeyFrameAnimation)CAKeyFrameAnimation.GetFromKeyPath(keyPath); a.KeyTimes = new NSNumber[] { new NSNumber(0), new NSNumber(0), new NSNumber(1) }; a.Values = new NSObject[] { new NSNumber(oldY), new NSNumber(half), new NSNumber(point.Y) }; a.Duration = duration; a.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); animations.Add(a); } CAAnimationGroup group = new CAAnimationGroup(); group.Duration = duration; group.Animations = animations.ToArray(); return(group); }
// >> chart-structure-animation-cs public override CAAnimation AnimationForSeries(TKChart chart, TKChartSeries series, TKChartSeriesRenderState state, CGRect rect) { var duration = 0.0; var animations = new List <CAAnimation> (); for (int i = 0; i < (int)state.Points.Count; i++) { var pointKeyPath = state.AnimationKeyPathForPointAtIndex((uint)i); var keyPath = pointKeyPath + ".x"; var point = state.Points.ObjectAtIndex((uint)i) as TKChartVisualPoint; var animation = new CABasicAnimation(); animation.KeyPath = keyPath; animation.Duration = (double)(r.Next(100)) / 100.0; animation.From = new NSNumber(0); animation.To = new NSNumber(point.X); animations.Add(animation); duration = Math.Max(animation.Duration, duration); } var group = new CAAnimationGroup(); group.Duration = duration; group.Animations = animations.ToArray(); return(group); }
public override CAAnimation AnimationForSeries(TKChart chart, TKChartSeries series, TKChartSeriesRenderState state, CGRect rect) { double duration = 0; List <CAAnimation> animations = new List <CAAnimation> (); for (int i = 0; i < (int)state.Points.Count; i++) { TKChartVisualPoint point = (TKChartVisualPoint)state.Points.ObjectAtIndex((uint)i); if (Grow) { string keyPath = string.Format("seriesRenderStates.{0}.points.{1}.x", series.Index, i); CABasicAnimation animation = (CABasicAnimation)CABasicAnimation.FromKeyPath(keyPath); animation.Duration = 0.1 * (i + 0.2); animation.From = new NSNumber(0); animation.To = new NSNumber(point.X); animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); animations.Add(animation); duration = animation.Duration; } else { string keyPath = string.Format("seriesRenderStates.{0}.points.{1}.y", series.Index, i); nfloat oldY = rect.Height; if (i > 0) { CAKeyFrameAnimation animation = (CAKeyFrameAnimation)CAKeyFrameAnimation.GetFromKeyPath(keyPath); animation.Duration = 0.1 * (i + 1); animation.Values = new NSNumber[] { new NSNumber(oldY), new NSNumber(oldY), new NSNumber(point.Y) }; animation.KeyTimes = new NSNumber[] { new NSNumber(0), new NSNumber(i / (i + 1.0)), new NSNumber(1) }; animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); animations.Add(animation); duration = animation.Duration; } else { CABasicAnimation animation = (CABasicAnimation)CABasicAnimation.FromKeyPath(keyPath); animation.From = new NSNumber(oldY); animation.To = new NSNumber(point.Y); animation.Duration = 0.1f; animations.Add(animation); } } } CAAnimationGroup group = new CAAnimationGroup(); group.Duration = duration; group.Animations = animations.ToArray(); return(group); }