public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { if (IsNew) { Canvas.SetTop(Slice, chart.DrawMargin.Height / 2); Canvas.SetLeft(Slice, chart.DrawMargin.Width / 2); Slice.WedgeAngle = 0; Slice.RotationAngle = 0; if (DataLabel != null) { Canvas.SetTop(DataLabel, 0d); Canvas.SetLeft(DataLabel, 0d); } } if (HoverShape != null) { var hs = (PieSlice)HoverShape; Canvas.SetTop(hs, chart.DrawMargin.Height / 2); Canvas.SetLeft(hs, chart.DrawMargin.Width / 2); hs.WedgeAngle = Wedge; hs.RotationAngle = Rotation; hs.InnerRadius = InnerRadius; hs.Radius = Radius; } Canvas.SetTop(Slice, chart.DrawMargin.Height / 2); Canvas.SetLeft(Slice, chart.DrawMargin.Width / 2); Slice.InnerRadius = InnerRadius; Slice.Radius = Radius; var hypo = (Slice.Radius + Slice.InnerRadius) / 2; var gamma = current.Participation * 360 / 2 + Rotation; var cp = new Point(hypo * Math.Sin(gamma * (Math.PI / 180)), hypo * Math.Cos(gamma * (Math.PI / 180))); if (chart.View.DisableAnimations) { Slice.WedgeAngle = Wedge; Slice.RotationAngle = Rotation; if (DataLabel != null) { DataLabel.UpdateLayout(); var lx = cp.X + chart.DrawMargin.Width / 2 - DataLabel.ActualWidth * .5; var ly = chart.DrawMargin.Height / 2 - cp.Y - DataLabel.ActualHeight * .5; Canvas.SetTop(DataLabel, lx); Canvas.SetLeft(DataLabel, ly); } return; } var animSpeed = chart.View.AnimationsSpeed; if (DataLabel != null) { DataLabel.UpdateLayout(); var lx = cp.X + chart.DrawMargin.Width / 2 - DataLabel.ActualWidth * .5; var ly = chart.DrawMargin.Height / 2 - cp.Y - DataLabel.ActualHeight * .5; DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(lx, animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(ly, animSpeed)); } Slice.BeginAnimation(PieSlice.WedgeAngleProperty, new DoubleAnimation(Wedge, animSpeed)); Slice.BeginAnimation(PieSlice.RotationAngleProperty, new DoubleAnimation(Rotation, animSpeed)); }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { var center = Left + Width / 2; if (IsNew) { HighToLowLine.X1 = center; HighToLowLine.X2 = center; HighToLowLine.Y1 = StartReference; HighToLowLine.Y2 = StartReference; OpenLine.X1 = Left; OpenLine.X2 = center; OpenLine.Y1 = StartReference; OpenLine.Y2 = StartReference; CloseLine.X1 = center; CloseLine.X2 = Left + Width; CloseLine.Y1 = StartReference; CloseLine.Y2 = StartReference; if (DataLabel != null) { Canvas.SetTop(DataLabel, current.ChartLocation.Y); Canvas.SetLeft(DataLabel, current.ChartLocation.X); } } if (HoverShape != null) { var h = Math.Abs(High - Low); HoverShape.Width = Width; HoverShape.Height = h > 10 ? h : 10; Canvas.SetLeft(HoverShape, Left); Canvas.SetTop(HoverShape, High); } if (chart.View.DisableAnimations) { HighToLowLine.Y1 = High; HighToLowLine.Y2 = Low; OpenLine.Y1 = Open; OpenLine.Y2 = Open; CloseLine.Y1 = Close; CloseLine.Y2 = Close; if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualHeight * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualWidth * .5, chart); Canvas.SetTop(DataLabel, cy); Canvas.SetLeft(DataLabel, cx); } return; } var animSpeed = chart.View.AnimationsSpeed; if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(cx, animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(cy, animSpeed)); } HighToLowLine.X1 = center; HighToLowLine.X2 = center; OpenLine.X1 = Left; OpenLine.X2 = center; CloseLine.X1 = center; CloseLine.X2 = Left + Width; HighToLowLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(High, animSpeed)); HighToLowLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Low, animSpeed)); OpenLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(Open, animSpeed)); OpenLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Open, animSpeed)); CloseLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(Close, animSpeed)); CloseLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Close, animSpeed)); }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { if (IsNew) { Canvas.SetTop(Shape, current.ChartLocation.Y); Canvas.SetLeft(Shape, current.ChartLocation.X); Shape.Width = 0; Shape.Height = 0; } if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel))) { Canvas.SetTop(DataLabel, current.ChartLocation.Y); Canvas.SetLeft(DataLabel, current.ChartLocation.X); } if (HoverShape != null) { HoverShape.Width = Diameter; HoverShape.Height = Diameter; Canvas.SetLeft(HoverShape, current.ChartLocation.X - Diameter / 2); Canvas.SetTop(HoverShape, current.ChartLocation.Y - Diameter / 2); } if (chart.View.DisableAnimations) { Shape.Width = Diameter; Shape.Height = Diameter; Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5); Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5); if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); Canvas.SetTop(DataLabel, cy); Canvas.SetLeft(DataLabel, cx); } return; } var animSpeed = chart.View.AnimationsSpeed; if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(cx, animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(cy, animSpeed)); } Shape.BeginAnimation(FrameworkElement.WidthProperty, new DoubleAnimation(Diameter, animSpeed)); Shape.BeginAnimation(FrameworkElement.HeightProperty, new DoubleAnimation(Diameter, animSpeed)); Shape.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(current.ChartLocation.Y - Diameter * .5, animSpeed)); Shape.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(current.ChartLocation.X - Diameter * .5, animSpeed)); }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { var previosPbv = previousDrawn == null ? null : (HBezierPointView)previousDrawn.View; var y = chart.DrawMargin.Top + chart.DrawMargin.Height; Container.Segments.Remove(Segment); Container.Segments.Insert(index, Segment); if (IsNew) { if (previosPbv != null && !previosPbv.IsNew) { Segment.Point1 = previosPbv.Segment.Point3; Segment.Point2 = previosPbv.Segment.Point3; Segment.Point3 = previosPbv.Segment.Point3; if (DataLabel != null) { Canvas.SetTop(DataLabel, Canvas.GetTop(previosPbv.DataLabel)); Canvas.SetLeft(DataLabel, Canvas.GetLeft(previosPbv.DataLabel)); } if (Shape != null) { Canvas.SetTop(Shape, Canvas.GetTop(previosPbv.Shape)); Canvas.SetLeft(Shape, Canvas.GetLeft(previosPbv.Shape)); } } else { Segment.Point1 = new Point(Data.Point1.X, y); Segment.Point2 = new Point(Data.Point2.X, y); Segment.Point3 = new Point(Data.Point3.X, y); if (DataLabel != null) { Canvas.SetTop(DataLabel, y); Canvas.SetLeft(DataLabel, current.ChartLocation.X - DataLabel.ActualWidth * .5); } if (Shape != null) { Canvas.SetTop(Shape, y); Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5); } } } #region No Animated if (chart.View.DisableAnimations) { Segment.Point1 = Data.Point1.AsPoint(); Segment.Point2 = Data.Point2.AsPoint(); Segment.Point3 = Data.Point3.AsPoint(); if (HoverShape != null) { Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width * .5); Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height * .5); } if (Shape != null) { Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5); Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5); } if (DataLabel != null) { DataLabel.UpdateLayout(); var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); Canvas.SetLeft(DataLabel, xl); Canvas.SetTop(DataLabel, yl); } return; } #endregion Segment.BeginAnimation(BezierSegment.Point1Property, new PointAnimation(Segment.Point1, Data.Point1.AsPoint(), chart.View.AnimationsSpeed)); Segment.BeginAnimation(BezierSegment.Point2Property, new PointAnimation(Segment.Point2, Data.Point2.AsPoint(), chart.View.AnimationsSpeed)); Segment.BeginAnimation(BezierSegment.Point3Property, new PointAnimation(Segment.Point3, Data.Point3.AsPoint(), chart.View.AnimationsSpeed)); if (Shape != null) { Shape.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(current.ChartLocation.X - Shape.Width * .5, chart.View.AnimationsSpeed)); Shape.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(current.ChartLocation.Y - Shape.Height * .5, chart.View.AnimationsSpeed)); } if (DataLabel != null) { DataLabel.UpdateLayout(); var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(xl, chart.View.AnimationsSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(yl, chart.View.AnimationsSpeed)); } if (HoverShape != null) { Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width * .5); Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height * .5); } }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { if (IsNew) { Canvas.SetTop(Rectangle, ZeroReference); Canvas.SetLeft(Rectangle, Data.Left); Rectangle.Width = Data.Width; Rectangle.Height = 0; } if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel))) { Canvas.SetTop(DataLabel, ZeroReference); Canvas.SetLeft(DataLabel, current.ChartLocation.X); } Func <double> getY = () => { double y; #pragma warning disable 618 if (LabelPosition == BarLabelPosition.Parallel || LabelPosition == BarLabelPosition.Merged) #pragma warning restore 618 { if (Transform == null) { Transform = new RotateTransform { Angle = 270 } } ; y = Data.Top + Data.Height / 2 + DataLabel.ActualWidth * .5; DataLabel.RenderTransform = Transform; } else if (LabelPosition == BarLabelPosition.Perpendicular) { y = Data.Top + Data.Height / 2 - DataLabel.ActualHeight * .5; } else { if (ZeroReference > Data.Top) { y = Data.Top - DataLabel.ActualHeight; if (y < 0) { y = Data.Top; } } else { y = Data.Top + Data.Height; if (y + DataLabel.ActualHeight > chart.DrawMargin.Height) { y -= DataLabel.ActualHeight; } } } return(y); }; Func <double> getX = () => { double x; #pragma warning disable 618 if (LabelPosition == BarLabelPosition.Parallel || LabelPosition == BarLabelPosition.Merged) #pragma warning restore 618 { x = Data.Left + Data.Width / 2 - DataLabel.ActualHeight / 2; } else if (LabelPosition == BarLabelPosition.Perpendicular) { x = Data.Left + Data.Width / 2 - DataLabel.ActualWidth / 2; } else { x = Data.Left + Data.Width / 2 - DataLabel.ActualWidth / 2; if (x < 0) { x = 2; } if (x + DataLabel.ActualWidth > chart.DrawMargin.Width) { x -= x + DataLabel.ActualWidth - chart.DrawMargin.Width + 2; } } return(x); }; if (chart.View.DisableAnimations) { Rectangle.Width = Data.Width; Rectangle.Height = Data.Height; Canvas.SetTop(Rectangle, Data.Top); Canvas.SetLeft(Rectangle, Data.Left); if (DataLabel != null) { DataLabel.UpdateLayout(); Canvas.SetTop(DataLabel, getY()); Canvas.SetLeft(DataLabel, getX()); } if (HoverShape != null) { Canvas.SetTop(HoverShape, Data.Top); Canvas.SetLeft(HoverShape, Data.Left); HoverShape.Height = Data.Height; HoverShape.Width = Data.Width; } return; } var animSpeed = chart.View.AnimationsSpeed; if (DataLabel != null) { DataLabel.UpdateLayout(); DataLabel.CreateCanvasStoryBoardAndBegin(getX(), getY(), animSpeed); } Rectangle.BeginDoubleAnimation("(Canvas.Left)", Data.Left, animSpeed); Rectangle.BeginDoubleAnimation("(Canvas.Top)", Data.Top, animSpeed); Rectangle.BeginDoubleAnimation("(Canvas.Height)", Data.Width, animSpeed); Rectangle.BeginDoubleAnimation(nameof(FrameworkElement.Height), Data.Height, animSpeed); if (HoverShape != null) { Canvas.SetTop(HoverShape, Data.Top); Canvas.SetLeft(HoverShape, Data.Left); HoverShape.Height = Data.Height; HoverShape.Width = Data.Width; } }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { if (IsNew) { Canvas.SetTop(Rectangle, Data.Top); Canvas.SetLeft(Rectangle, ZeroReference); Rectangle.Width = 0; Rectangle.Height = Data.Height; if (DataLabel != null) { Canvas.SetTop(DataLabel, Data.Top); Canvas.SetLeft(DataLabel, ZeroReference); } } Func <double> getY = () => { var r = Data.Top + Data.Height / 2 - DataLabel.ActualHeight / 2; if (r < 0) { r = 2; } if (r + DataLabel.ActualHeight > chart.DrawMargin.Height) { r -= r + DataLabel.ActualHeight - chart.DrawMargin.Height + 2; } return(r); }; Func <double> getX = () => { double r; if (LabelInside) { r = Data.Left + Data.Width / 2 - DataLabel.ActualWidth / 2; } else { if (Data.Left < ZeroReference) { r = Data.Left - DataLabel.ActualWidth - 5; if (r < 0) { r = Data.Left + 5; } } else { r = Data.Left + Data.Width + 5; if (r + DataLabel.ActualWidth > chart.DrawMargin.Width) { r -= DataLabel.ActualWidth + 10; } } } return(r); }; if (chart.View.DisableAnimations) { Rectangle.Width = Data.Width; Rectangle.Height = Data.Height; Canvas.SetTop(Rectangle, Data.Top); Canvas.SetLeft(Rectangle, Data.Left); if (DataLabel != null) { DataLabel.UpdateLayout(); Canvas.SetTop(DataLabel, getY()); Canvas.SetLeft(DataLabel, getX()); } if (HoverShape != null) { Canvas.SetTop(HoverShape, Data.Top); Canvas.SetLeft(HoverShape, Data.Left); HoverShape.Height = Data.Height; HoverShape.Width = Data.Width; } return; } var animSpeed = chart.View.AnimationsSpeed; if (DataLabel != null) { DataLabel.UpdateLayout(); DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(getX(), animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(getY(), animSpeed)); } Canvas.SetTop(Rectangle, Data.Top); Rectangle.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(Data.Left, animSpeed)); Rectangle.Height = Data.Height; Rectangle.BeginAnimation(FrameworkElement.WidthProperty, new DoubleAnimation(Data.Width, animSpeed)); if (HoverShape != null) { Canvas.SetTop(HoverShape, Data.Top); Canvas.SetLeft(HoverShape, Data.Left); HoverShape.Height = Data.Height; HoverShape.Width = Data.Width; } }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { var previosPbv = previousDrawn == null ? null : (VerticalBezierPointView)previousDrawn.View; Container.Segments.Remove(Segment); Container.Segments.Insert(index, Segment); if (IsNew) { if (previosPbv != null && !previosPbv.IsNew) { Segment.Point1 = previosPbv.Segment.Point3; Segment.Point2 = previosPbv.Segment.Point3; Segment.Point3 = previosPbv.Segment.Point3; if (DataLabel != null) { Canvas.SetTop(DataLabel, Canvas.GetTop(previosPbv.DataLabel)); Canvas.SetLeft(DataLabel, Canvas.GetLeft(previosPbv.DataLabel)); } if (Shape != null) { Canvas.SetTop(Shape, Canvas.GetTop(previosPbv.Shape)); Canvas.SetLeft(Shape, Canvas.GetLeft(previosPbv.Shape)); } } else { Segment.Point1 = new Point(0, Data.Point1.Y); Segment.Point2 = new Point(0, Data.Point2.Y); Segment.Point3 = new Point(0, Data.Point3.Y); if (DataLabel != null) { Canvas.SetTop(DataLabel, current.ChartLocation.Y - DataLabel.ActualHeight * .5); Canvas.SetLeft(DataLabel, 0); } if (Shape != null) { Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5); Canvas.SetLeft(Shape, 0); } } } else if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel))) { Canvas.SetTop(DataLabel, current.ChartLocation.Y - DataLabel.ActualHeight * .5); Canvas.SetLeft(DataLabel, 0); } #region No Animated if (chart.View.DisableAnimations) { Segment.Point1 = Data.Point1.AsPoint(); Segment.Point2 = Data.Point2.AsPoint(); Segment.Point3 = Data.Point3.AsPoint(); if (HoverShape != null) { Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width * .5); Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height * .5); } if (Shape != null) { Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5); Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5); } if (DataLabel != null) { DataLabel.UpdateLayout(); var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); Canvas.SetLeft(DataLabel, xl); Canvas.SetTop(DataLabel, yl); } return; } #endregion var animSpeed = chart.View.AnimationsSpeed; Segment.BeginPointAnimation(nameof(BezierSegment.Point1), Data.Point1.AsPoint(), animSpeed); Segment.BeginPointAnimation(nameof(BezierSegment.Point2), Data.Point2.AsPoint(), animSpeed); Segment.BeginPointAnimation(nameof(BezierSegment.Point3), Data.Point3.AsPoint(), animSpeed); if (Shape != null) { if (double.IsNaN(Canvas.GetLeft(Shape))) { Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5); Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5); } else { var storyBoard = new Storyboard(); var xAnimation = new DoubleAnimation() { To = current.ChartLocation.X - Shape.Width * .5, Duration = chart.View.AnimationsSpeed }; var yAnimation = new DoubleAnimation() { To = current.ChartLocation.Y - Shape.Height * .5, Duration = chart.View.AnimationsSpeed }; Storyboard.SetTarget(xAnimation, Shape); Storyboard.SetTarget(yAnimation, Shape); Storyboard.SetTargetProperty(xAnimation, "(Canvas.Left)"); Storyboard.SetTargetProperty(yAnimation, "(Canvas.Top)"); storyBoard.Children.Add(xAnimation); storyBoard.Children.Add(yAnimation); storyBoard.Begin(); } } if (DataLabel != null) { DataLabel.UpdateLayout(); var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); var storyBoard = new Storyboard(); var xAnimation = new DoubleAnimation() { To = xl, Duration = chart.View.AnimationsSpeed }; var yAnimation = new DoubleAnimation() { To = yl, Duration = chart.View.AnimationsSpeed }; Storyboard.SetTarget(xAnimation, DataLabel); Storyboard.SetTarget(yAnimation, DataLabel); Storyboard.SetTargetProperty(xAnimation, "(Canvas.Left)"); Storyboard.SetTargetProperty(yAnimation, "(Canvas.Top)"); storyBoard.Children.Add(xAnimation); storyBoard.Children.Add(yAnimation); storyBoard.Begin(); } if (HoverShape != null) { Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width * .5); Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height * .5); } }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { if (IsNew) { Canvas.SetTop(Rectangle, Data.Top); Canvas.SetLeft(Rectangle, ZeroReference); Rectangle.Width = 0; Rectangle.Height = Data.Height; } if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel))) { Canvas.SetTop(DataLabel, Data.Top); Canvas.SetLeft(DataLabel, ZeroReference); } Func <double> getY = () => { if (LabelPosition == BarLabelPosition.Perpendicular) { if (Transform == null) { Transform = new RotateTransform(270); } DataLabel.RenderTransform = Transform; return(Data.Top + Data.Height / 2 + DataLabel.ActualWidth * .5); } var r = Data.Top + Data.Height / 2 - DataLabel.ActualHeight / 2; if (r < 0) { r = 2; } if (r + DataLabel.ActualHeight > chart.DrawMargin.Height) { r -= r + DataLabel.ActualHeight - chart.DrawMargin.Height + 2; } return(r); }; Func <double> getX = () => { double r; #pragma warning disable 618 if (LabelPosition == BarLabelPosition.Parallel || LabelPosition == BarLabelPosition.Merged) #pragma warning restore 618 { r = Data.Left + Data.Width / 2 - DataLabel.ActualWidth / 2; } else if (LabelPosition == BarLabelPosition.Perpendicular) { r = Data.Left + Data.Width / 2 - DataLabel.ActualHeight / 2; } else { if (Data.Left < ZeroReference) { r = Data.Left - DataLabel.ActualWidth - 5; if (r < 0) { r = Data.Left + 5; } } else { r = Data.Left + Data.Width + 5; if (r + DataLabel.ActualWidth > chart.DrawMargin.Width) { r -= DataLabel.ActualWidth + 10; } } } return(r); }; if (chart.View.DisableAnimations) { Rectangle.Width = Data.Width; Rectangle.Height = Data.Height; Canvas.SetTop(Rectangle, Data.Top); Canvas.SetLeft(Rectangle, Data.Left); if (DataLabel != null) { DataLabel.UpdateLayout(); Canvas.SetTop(DataLabel, getY()); Canvas.SetLeft(DataLabel, getX()); } if (HoverShape != null) { Canvas.SetTop(HoverShape, Data.Top); Canvas.SetLeft(HoverShape, Data.Left); HoverShape.Height = Data.Height; HoverShape.Width = Data.Width; } return; } var animSpeed = chart.View.AnimationsSpeed; //if (double.IsNaN(getX()) || double.IsNaN(getY()) // return; if (DataLabel != null) { DataLabel.UpdateLayout(); DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(getX(), animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(getY(), animSpeed)); } Rectangle.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(Data.Top, animSpeed)); Rectangle.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(Data.Left, animSpeed)); Rectangle.BeginAnimation(FrameworkElement.HeightProperty, new DoubleAnimation(Data.Height, animSpeed)); Rectangle.BeginAnimation(FrameworkElement.WidthProperty, new DoubleAnimation(Data.Width, animSpeed)); if (HoverShape != null) { Canvas.SetTop(HoverShape, Data.Top); Canvas.SetLeft(HoverShape, Data.Left); HoverShape.Height = Data.Height; HoverShape.Width = Data.Width; } }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { if (IsNew) { VerticalLine.X1 = current.ChartLocation.X; VerticalLine.X2 = current.ChartLocation.X; VerticalLine.Y1 = chart.DrawMargin.Height; VerticalLine.Y2 = chart.DrawMargin.Height; HorizontalLine.X1 = current.ChartLocation.X - DeltaX; HorizontalLine.X2 = current.ChartLocation.X; HorizontalLine.Y1 = chart.DrawMargin.Height; HorizontalLine.Y2 = chart.DrawMargin.Height; if (Shape != null) { Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width / 2); Canvas.SetTop(Shape, chart.DrawMargin.Height); } if (DataLabel != null) { Canvas.SetTop(DataLabel, chart.DrawMargin.Height); Canvas.SetLeft(DataLabel, current.ChartLocation.X); } } if (HoverShape != null) { HoverShape.Width = Shape != null ? (Shape.Width > 5 ? Shape.Width : 5) : 5; HoverShape.Height = Shape != null ? (Shape.Height > 5 ? Shape.Height : 5) : 5; Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width / 2); Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height / 2); } if (chart.View.DisableAnimations) { VerticalLine.X1 = current.ChartLocation.X; VerticalLine.X2 = current.ChartLocation.X; VerticalLine.Y1 = current.ChartLocation.Y; VerticalLine.Y2 = current.ChartLocation.Y - DeltaY; HorizontalLine.X1 = current.ChartLocation.X - DeltaX; HorizontalLine.X2 = current.ChartLocation.X; HorizontalLine.Y1 = current.ChartLocation.Y - DeltaY; HorizontalLine.Y2 = current.ChartLocation.Y - DeltaY; if (Shape != null) { Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width / 2); Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height / 2); } if (DataLabel != null) { DataLabel.UpdateLayout(); var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); Canvas.SetLeft(DataLabel, xl); Canvas.SetTop(DataLabel, yl); } return; } var animSpeed = chart.View.AnimationsSpeed; VerticalLine.BeginDoubleAnimation(nameof(Line.X1), current.ChartLocation.X, animSpeed); VerticalLine.BeginDoubleAnimation(nameof(Line.X2), current.ChartLocation.X, animSpeed); VerticalLine.BeginDoubleAnimation(nameof(Line.Y1), current.ChartLocation.Y, animSpeed); VerticalLine.BeginDoubleAnimation(nameof(Line.Y2), current.ChartLocation.Y - DeltaY, animSpeed); HorizontalLine.BeginDoubleAnimation(nameof(Line.X1), current.ChartLocation.X - DeltaX, animSpeed); HorizontalLine.BeginDoubleAnimation(nameof(Line.X2), current.ChartLocation.X, animSpeed); HorizontalLine.BeginDoubleAnimation(nameof(Line.Y1), current.ChartLocation.Y - DeltaY, animSpeed); HorizontalLine.BeginDoubleAnimation(nameof(Line.Y2), current.ChartLocation.Y - DeltaY, animSpeed); Shape?.CreateCanvasStoryBoardAndBegin(current.ChartLocation.X - Shape.Width / 2, current.ChartLocation.Y - Shape.Height / 2, animSpeed); if (DataLabel == null) { return; } { DataLabel.UpdateLayout(); var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); Canvas.SetLeft(DataLabel, xl); Canvas.SetTop(DataLabel, yl); } }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { var center = Left + Width / 2; if (IsNew) { HighToLowLine.X1 = center; HighToLowLine.X2 = center; HighToLowLine.Y1 = StartReference; HighToLowLine.Y2 = StartReference; Canvas.SetTop(OpenToCloseRectangle, (Open + Close) / 2); Canvas.SetLeft(OpenToCloseRectangle, Left); OpenToCloseRectangle.Width = Width; OpenToCloseRectangle.Height = 0; if (DataLabel != null) { Canvas.SetTop(DataLabel, current.ChartLocation.Y); Canvas.SetLeft(DataLabel, current.ChartLocation.X); } } if (HoverShape != null) { var h = Math.Abs(High - Low); HoverShape.Width = Width; HoverShape.Height = h > 10 ? h : 10; Canvas.SetLeft(HoverShape, Left); Canvas.SetTop(HoverShape, High); } if (chart.View.DisableAnimations) { HighToLowLine.Y1 = High; HighToLowLine.Y2 = Low; HighToLowLine.X1 = center; HighToLowLine.X2 = center; OpenToCloseRectangle.Width = Width; OpenToCloseRectangle.Height = Math.Abs(Open - Close); Canvas.SetTop(OpenToCloseRectangle, Math.Min(Open, Close)); Canvas.SetLeft(OpenToCloseRectangle, Left); if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualHeight * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualWidth * .5, chart); Canvas.SetTop(DataLabel, cy); Canvas.SetLeft(DataLabel, cx); } return; } var animSpeed = chart.View.AnimationsSpeed; if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); DataLabel.CreateCanvasStoryBoardAndBegin(cx, cy, animSpeed); } var x1Animation = AnimationsHelper.CreateDouble(center, animSpeed, "Line.X1"); var x2Animation = AnimationsHelper.CreateDouble(center, animSpeed, "Line.X2"); AnimationsHelper.CreateStoryBoard(HighToLowLine, x1Animation, x2Animation); var y1Animation = AnimationsHelper.CreateDouble(High, animSpeed, "Line.Y1"); var y2Animation = AnimationsHelper.CreateDouble(Low, animSpeed, "Line.Y2"); AnimationsHelper.CreateStoryBoardAndBegin(HighToLowLine, y1Animation, y2Animation); OpenToCloseRectangle.BeginDoubleAnimation("(Canvas.Left)", Left, animSpeed); OpenToCloseRectangle.BeginDoubleAnimation("(Canvas.Top)", Math.Min(Open, Close), animSpeed); OpenToCloseRectangle.BeginDoubleAnimation("Width", Width, animSpeed); OpenToCloseRectangle.BeginDoubleAnimation("Height", Math.Max(Math.Abs(Open - Close), OpenToCloseRectangle.StrokeThickness), animSpeed); }