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) { 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 (LabelPosition == BarLabelPosition.Merged) { 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); ValidArea = new CoreRectangle(current.ChartLocation.X - 7.5, current.ChartLocation.Y - 7.5, 15, 15); 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 { if (current.SeriesView.IsFirstDraw) { 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 (Shape != null) { Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5); Canvas.SetLeft(Shape, 0); } if (DataLabel != null) { Canvas.SetTop(DataLabel, current.ChartLocation.Y - DataLabel.ActualHeight * .5); Canvas.SetLeft(DataLabel, 0); } } else { var startPoint = ((LineSeries)current.SeriesView).Splitters[0].Left.Point; Segment.Point1 = startPoint; Segment.Point2 = startPoint; Segment.Point3 = startPoint; if (Shape != null) { Canvas.SetTop(Shape, startPoint.Y - Shape.Height * .5); Canvas.SetLeft(Shape, startPoint.X); } if (DataLabel != null) { Canvas.SetTop(DataLabel, startPoint.Y - DataLabel.ActualHeight * .5); Canvas.SetLeft(DataLabel, startPoint.X); } } } } 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 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) { 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 { 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) { 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 (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel))) { 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; OpenLine.Y1 = Open; OpenLine.Y2 = Open; OpenLine.X1 = Left; OpenLine.X2 = center; CloseLine.Y1 = Close; CloseLine.Y2 = Close; CloseLine.X1 = center; CloseLine.X2 = Left + Width; 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.BeginAnimation(Line.X1Property, new DoubleAnimation(center, animSpeed)); HighToLowLine.BeginAnimation(Line.X2Property, new DoubleAnimation(center, animSpeed)); OpenLine.BeginAnimation(Line.X1Property, new DoubleAnimation(Left, animSpeed)); OpenLine.BeginAnimation(Line.X2Property, new DoubleAnimation(center, animSpeed)); CloseLine.BeginAnimation(Line.X1Property, new DoubleAnimation(center, animSpeed)); CloseLine.BeginAnimation(Line.X2Property, new DoubleAnimation(Left + Width, animSpeed)); 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(Slice, chart.DrawMargin.Height / 2); Canvas.SetLeft(Slice, chart.DrawMargin.Width / 2); Slice.WedgeAngle = 0; Slice.RotationAngle = 0; } if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel))) { Canvas.SetTop(DataLabel, chart.DrawMargin.Height / 2); Canvas.SetLeft(DataLabel, chart.DrawMargin.Width / 2); } 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; } var lh = 0d; if (DataLabel != null) { DataLabel.UpdateLayout(); lh = DataLabel.ActualHeight; } var hypo = ((PieSeries)current.SeriesView).LabelPosition == PieLabelPosition.InsideSlice ? (Radius + InnerRadius) * (Math.Abs(InnerRadius) < 0.01 ? .65 : .5) : Radius + lh; 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.InnerRadius = InnerRadius; Slice.Radius = Radius; Slice.WedgeAngle = Wedge; Slice.RotationAngle = Rotation; Canvas.SetTop(Slice, chart.DrawMargin.Height / 2); Canvas.SetLeft(Slice, chart.DrawMargin.Width / 2); if (DataLabel != null) { var lx = cp.X + chart.DrawMargin.Width / 2 - DataLabel.ActualWidth * .5; var ly = chart.DrawMargin.Height / 2 - cp.Y - DataLabel.ActualHeight * .5; Canvas.SetLeft(DataLabel, lx); Canvas.SetTop(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(Canvas.LeftProperty, new DoubleAnimation(chart.DrawMargin.Width / 2, animSpeed)); Slice.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(chart.DrawMargin.Height / 2, animSpeed)); Slice.BeginAnimation(PieSlice.InnerRadiusProperty, new DoubleAnimation(InnerRadius, animSpeed)); Slice.BeginAnimation(PieSlice.RadiusProperty, new DoubleAnimation(Radius, 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) { if (IsNew) { Canvas.SetTop(Ellipse, current.ChartLocation.Y); Canvas.SetLeft(Ellipse, current.ChartLocation.X); Ellipse.Width = 0; Ellipse.Height = 0; if (DataLabel != null) { 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) { Ellipse.Width = Diameter; Ellipse.Height = Diameter; Canvas.SetTop(Ellipse, current.ChartLocation.Y - Ellipse.Width * .5); Canvas.SetLeft(Ellipse, current.ChartLocation.X - Ellipse.Height * .5); if (DataLabel != null) { DataLabel.UpdateLayout(); var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualHeight * .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)); } Ellipse.BeginAnimation(FrameworkElement.WidthProperty, new DoubleAnimation(Diameter, animSpeed)); Ellipse.BeginAnimation(FrameworkElement.HeightProperty, new DoubleAnimation(Diameter, animSpeed)); Ellipse.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(current.ChartLocation.Y - Diameter * .5, animSpeed)); Ellipse.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(current.ChartLocation.X - Diameter * .5, 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; Canvas.SetTop(OpenToCloseRectangle, (Open + Close) / 2); Canvas.SetLeft(OpenToCloseRectangle, Left); OpenToCloseRectangle.Width = Width; OpenToCloseRectangle.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) { var h = Math.Abs(High - Low); HoverShape.Width = Width; HoverShape.Height = h > 10 ? h : 10; Canvas.SetLeft(HoverShape, Left); Canvas.SetTop(HoverShape, High); } var candleSeries = (CandleSeries)current.SeriesView; if (candleSeries.ColoringRules == null) { if (current.Open <= current.Close) { HighToLowLine.Stroke = candleSeries.IncreaseBrush; OpenToCloseRectangle.Fill = candleSeries.IncreaseBrush; OpenToCloseRectangle.Stroke = candleSeries.IncreaseBrush; } else { HighToLowLine.Stroke = candleSeries.DecreaseBrush; OpenToCloseRectangle.Fill = candleSeries.DecreaseBrush; OpenToCloseRectangle.Stroke = candleSeries.DecreaseBrush; } } else { foreach (var rule in candleSeries.ColoringRules) { if (!rule.Condition(current, previousDrawn)) { continue; } HighToLowLine.Stroke = rule.Stroke; OpenToCloseRectangle.Fill = rule.Fill; OpenToCloseRectangle.Stroke = rule.Stroke; break; } } if (chart.View.DisableAnimations) { HighToLowLine.Y1 = High; HighToLowLine.Y2 = Low; HighToLowLine.X1 = center; HighToLowLine.X2 = center; double Abs = Math.Abs(Open - Close); OpenToCloseRectangle.Width = Width; OpenToCloseRectangle.Height = Abs > 1 ? Abs : 1; 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.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(cx, animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(cy, animSpeed)); } HighToLowLine.BeginAnimation(Line.X1Property, new DoubleAnimation(center, animSpeed)); HighToLowLine.BeginAnimation(Line.X2Property, new DoubleAnimation(center, animSpeed)); HighToLowLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(High, animSpeed)); HighToLowLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Low, animSpeed)); OpenToCloseRectangle.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(Left, animSpeed)); OpenToCloseRectangle.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(Math.Min(Open, Close), animSpeed)); OpenToCloseRectangle.BeginAnimation(FrameworkElement.WidthProperty, new DoubleAnimation(Width, animSpeed)); OpenToCloseRectangle.BeginAnimation(FrameworkElement.HeightProperty, new DoubleAnimation(Math.Max(Math.Abs(Open - Close), OpenToCloseRectangle.StrokeThickness), animSpeed)); }
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) { Canvas.SetTop(DataLabel, ZeroReference); Canvas.SetLeft(DataLabel, current.ChartLocation.X); } } Func <double> getY = () => { double y; if (LabelInside) { if (RotateTransform == null) { RotateTransform = new RotateTransform(270); } DataLabel.RenderTransform = RotateTransform; y = Data.Top + Data.Height / 2 + DataLabel.ActualWidth * .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; if (LabelInside) { x = Data.Left + Data.Width / 2 - DataLabel.ActualHeight / 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.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(getX(), animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(getY(), animSpeed)); } Canvas.SetLeft(Rectangle, Data.Left); Rectangle.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(Data.Top, animSpeed)); Rectangle.Width = Data.Width; Rectangle.BeginAnimation(FrameworkElement.HeightProperty, new DoubleAnimation(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) { 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; 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.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(cx, animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(cy, animSpeed)); } HighToLowLine.BeginAnimation(Line.X1Property, new DoubleAnimation(center, animSpeed)); HighToLowLine.BeginAnimation(Line.X2Property, new DoubleAnimation(center, animSpeed)); HighToLowLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(High, animSpeed)); HighToLowLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Low, animSpeed)); OpenToCloseRectangle.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(Left, animSpeed)); OpenToCloseRectangle.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(Math.Min(Open, Close), animSpeed)); OpenToCloseRectangle.BeginAnimation(FrameworkElement.WidthProperty, new DoubleAnimation(Width, animSpeed)); OpenToCloseRectangle.BeginAnimation(FrameworkElement.HeightProperty, new DoubleAnimation(Math.Max(Math.Abs(Open - Close), OpenToCloseRectangle.StrokeThickness), 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 (Ellipse != null) { Canvas.SetTop(Ellipse, Canvas.GetTop(previosPbv.Ellipse)); Canvas.SetLeft(Ellipse, Canvas.GetLeft(previosPbv.Ellipse)); } } 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 (Ellipse != null) { Canvas.SetTop(Ellipse, y); Canvas.SetLeft(Ellipse, current.ChartLocation.X - Ellipse.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 (Ellipse != null) { Canvas.SetLeft(Ellipse, current.ChartLocation.X - Ellipse.Width * .5); Canvas.SetTop(Ellipse, current.ChartLocation.Y - Ellipse.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 (Ellipse != null) { Ellipse.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(current.ChartLocation.X - Ellipse.Width * .5, chart.View.AnimationsSpeed)); Ellipse.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(current.ChartLocation.Y - Ellipse.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.ParallelTopRight || LabelPosition == BarLabelPosition.ParallelBottomLeft || LabelPosition == BarLabelPosition.Merged) #pragma warning restore 618 { if (Transform == null) { Transform = new RotateTransform(270); } DataLabel.RenderTransform = Transform; if (LabelPosition == BarLabelPosition.ParallelTopRight) { y = Data.Top + DataLabel.ActualWidth; } else if (LabelPosition == BarLabelPosition.ParallelBottomLeft) { y = Data.Top + Data.Height; } else { y = Data.Top + Data.Height / 2 + DataLabel.ActualWidth * .5; } } 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.ParallelTopRight || LabelPosition == BarLabelPosition.ParallelBottomLeft || 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.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(getX(), animSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(getY(), animSpeed)); } Rectangle.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(Data.Left, animSpeed)); Rectangle.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(Data.Top, animSpeed)); Rectangle.BeginAnimation(FrameworkElement.WidthProperty, new DoubleAnimation(Data.Width, animSpeed)); Rectangle.BeginAnimation(FrameworkElement.HeightProperty, new DoubleAnimation(Data.Height, animSpeed)); if (HoverShape != null) { Canvas.SetTop(HoverShape, Data.Top); Canvas.SetLeft(HoverShape, Data.Left); HoverShape.Height = Data.Height; HoverShape.Width = Data.Width; } }