Example #1
0
        /// <summary>
        /// Adds the or move.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// </exception>
        public void AddOrMove(ChartCore chart)
        {
            if (chart == null || UIElement == null)
            {
                return;
            }
            if (!chart.AreComponentsLoaded)
            {
                return;
            }

            if (UIElement.Parent == null)
            {
                chart.View.AddToDrawMargin(UIElement);
                Panel.SetZIndex(UIElement, 1000);
            }

            var coordinate = new CorePoint(ChartFunctions.ToDrawMargin(X, AxisOrientation.X, chart, AxisX),
                                           ChartFunctions.ToDrawMargin(Y, AxisOrientation.Y, chart.View.Model, AxisY));

            var wpfChart = (CartesianChart)chart.View;

            var uw = new CorePoint(
                wpfChart.AxisX[AxisX].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart, AxisX) / 2
                    : 0,
                wpfChart.AxisY[AxisY].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart, AxisY) / 2
                    : 0);

            if (IsScaledWithChart)
            {
                const int INFINITECIMAL = 0;//can assume we're dealing with date time ticks at this point?  GetUnitWidth does not work for long type (loses precision)
                if (uw.X == INFINITECIMAL)
                {
                    var min        = ((Chart)chart.View).AxisX[AxisX].ActualMinValue;
                    var max        = ((Chart)chart.View).AxisX[AxisX].ActualMaxValue;
                    var valueWidth = max - min;
                    var viewWidth  = ((Chart)chart.View).DrawMargin.ActualWidth;
                    var newWidth   = ScaleXRatio / valueWidth * viewWidth;

                    UIElement.Width = newWidth;
                    coordinate.X    = coordinate.X - (newWidth / 2);
                }
                else
                {
                    UIElement.Width = uw.X * 2 * ScaleYRatio;
                    coordinate.X   += uw.X;
                }
                if (uw.Y == INFINITECIMAL)
                {
                    var min         = ((Chart)chart.View).AxisY[AxisY].ActualMinValue;
                    var max         = ((Chart)chart.View).AxisY[AxisY].ActualMaxValue;
                    var valueHeight = max - min;
                    var viewHeight  = ((Chart)chart.View).DrawMargin.ActualHeight;
                    var newHeight   = ScaleYRatio / valueHeight * viewHeight;

                    UIElement.Height = newHeight;
                    coordinate.Y     = coordinate.Y - (newHeight / 2);
                }
                else
                {
                    UIElement.Height = uw.Y * 2 * ScaleYRatio;
                    coordinate.Y    += uw.Y;
                }
            }
            else
            {
                coordinate += uw;
            }

            UIElement.UpdateLayout();

            switch (VerticalAlignment)
            {
            case VerticalAlignment.Top:
                coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight);
                break;

            case VerticalAlignment.Center:
                coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight / 2);
                break;

            case VerticalAlignment.Bottom:
                coordinate = new CorePoint(coordinate.X, coordinate.Y);
                break;

            case VerticalAlignment.Stretch:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (HorizontalAlignment)
            {
            case HorizontalAlignment.Left:
                coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth, coordinate.Y);
                break;

            case HorizontalAlignment.Center:
                coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth / 2, coordinate.Y);
                break;

            case HorizontalAlignment.Right:
                coordinate = new CorePoint(coordinate.X, coordinate.Y);
                break;

            case HorizontalAlignment.Stretch:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (chart.View.DisableAnimations)
            {
                Canvas.SetLeft(UIElement, coordinate.X);
                Canvas.SetTop(UIElement, coordinate.Y);
            }
            else
            {
                if (double.IsNaN(Canvas.GetLeft(UIElement)))
                {
                    Canvas.SetLeft(UIElement, coordinate.X);
                    Canvas.SetTop(UIElement, coordinate.Y);
                }
                UIElement.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(coordinate.X, wpfChart.AnimationsSpeed));
                UIElement.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(coordinate.Y, wpfChart.AnimationsSpeed));
            }

            _owner = chart;
        }
Example #2
0
        internal void UpdateSeparators(AxisOrientation source, ChartCore chart, int axisIndex)
        {
            foreach (var element in Cache.Values.ToArray())
            {
                if (element.GarbageCollectorIndex < GarbageCollectorIndex)
                {
                    element.State = SeparationState.Remove;
                    Cache.Remove(element.Key);
                }

                var toLine = ChartFunctions.ToPlotArea(element.Value, source, chart, axisIndex);

                var direction = source == AxisOrientation.X ? 1 : -1;

                toLine += EvaluatesUnitWidth ? direction * ChartFunctions.GetUnitWidth(source, chart, this) / 2 : 0;
                var toLabel = toLine + element.View.LabelModel.GetOffsetBySource(source);

                if (IsMerged)
                {
                    const double padding = 4;

                    if (source == AxisOrientation.Y)
                    {
                        if (toLabel + element.View.LabelModel.ActualHeight >
                            chart.DrawMargin.Top + chart.DrawMargin.Height)
                        {
                            toLabel -= element.View.LabelModel.ActualHeight + padding;
                        }
                    }
                    else
                    {
                        if (toLabel + element.View.LabelModel.ActualWidth >
                            chart.DrawMargin.Left + chart.DrawMargin.Width)
                        {
                            toLabel -= element.View.LabelModel.ActualWidth + padding;
                        }
                    }
                }

                var labelTab = Tab;
                labelTab += element.View.LabelModel.GetOffsetBySource(source.Invert());

                switch (element.State)
                {
                case SeparationState.Remove:
                    if (!chart.View.DisableAnimations && !View.DisableAnimations)
                    {
                        element.View.Move(chart, this, source, axisIndex, toLabel, toLine, labelTab);
                        element.View.FadeOutAndRemove(chart);
                    }
                    else
                    {
                        element.View.Remove(chart);
                    }
                    break;

                case SeparationState.Keep:
                    if (!chart.View.DisableAnimations && !View.DisableAnimations)
                    {
                        if (element.IsNew)
                        {
                            var toLinePrevious = FromPreviousState(element.Value, source, chart);
                            toLinePrevious += EvaluatesUnitWidth ? ChartFunctions.GetUnitWidth(source, chart, this) / 2 : 0;
                            var toLabelPrevious = toLinePrevious + element.View.LabelModel.GetOffsetBySource(source);
                            element.View.Place(chart, this, source, axisIndex, toLabelPrevious,
                                               toLinePrevious, labelTab);
                            element.View.FadeIn(this, chart);
                        }
                        element.View.Move(chart, this, source, axisIndex, toLabel, toLine, labelTab);
                    }
                    else
                    {
                        element.View.Place(chart, this, source, axisIndex, toLabel, toLine, labelTab);
                    }
                    break;

                case SeparationState.InitialAdd:
                    element.View.Place(chart, this, source, axisIndex, toLabel, toLine, labelTab);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            LastAxisMax  = TopLimit;
            LastAxisMin  = BotLimit;
            LastPlotArea = new CoreRectangle(chart.DrawMargin.Left, chart.DrawMargin.Top,
                                             chart.DrawMargin.Width, chart.DrawMargin.Height);

#if DEBUG
            Debug.WriteLine("Axis.Separations: " + Cache.Count);
#endif
        }
 public override void RemoveFromView(ChartCore chart)
 {
     chart.View.RemoveFromDrawMargin(HoverShape);
     chart.View.RemoveFromDrawMargin(Shape);
     chart.View.RemoveFromDrawMargin(DataLabel);
 }
        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 (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 (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
            {
                Canvas.SetTop(DataLabel, current.ChartLocation.Y);
                Canvas.SetLeft(DataLabel, current.ChartLocation.X);
            }

            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;

                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);
            }

            HighToLowLine.BeginDoubleAnimation("Line.X1", center, animSpeed);
            HighToLowLine.BeginDoubleAnimation("Line.X2", center, animSpeed);
            OpenLine.BeginDoubleAnimation("Line.X1", Left, animSpeed);
            OpenLine.BeginDoubleAnimation("Line.X2", center, animSpeed);
            CloseLine.BeginDoubleAnimation("Line.X1", center, animSpeed);
            CloseLine.BeginDoubleAnimation("Line.X2", center, animSpeed);

            HighToLowLine.CreateY1Y2StoryBoardAndBegin(High, Low, animSpeed);
            OpenLine.CreateY1Y2StoryBoardAndBegin(Open, Open, animSpeed);
            CloseLine.CreateY1Y2StoryBoardAndBegin(Close, Close, animSpeed);
        }
Example #5
0
        public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
        {
            var previosPbv = previousDrawn == null
                ? null
                : (HorizontalBezierPointView)previousDrawn.View;

            var y = chart.DrawMargin.Top + chart.DrawMargin.Height;

            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
                {
                    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)
            {
                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);
            }
        }
Example #6
0
 public List <AxisCore> MapYAxes(ChartCore chart)
 {
     throw new NotImplementedException();
 }
Example #7
0
        public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
        {
            Canvas.SetTop(Rectangle, current.ChartLocation.Y);
            Canvas.SetLeft(Rectangle, current.ChartLocation.X);

            Rectangle.Width  = Width;
            Rectangle.Height = Height;

            if (IsNew)
            {
                Rectangle.Fill = new SolidColorBrush(Colors.Transparent);
            }

            if (HoverShape != null)
            {
                HoverShape.Width  = Width;
                HoverShape.Height = Height;
                Canvas.SetLeft(HoverShape, current.ChartLocation.X);
                Canvas.SetTop(HoverShape, current.ChartLocation.Y);
            }

            if (DataLabel != null)
            {
                DataLabel.UpdateLayout();
                Canvas.SetTop(DataLabel, current.ChartLocation.Y + (Height / 2) - DataLabel.ActualHeight * .5);
                Canvas.SetLeft(DataLabel, current.ChartLocation.X + (Width / 2) - DataLabel.ActualWidth * .5);
            }

            var targetColor = new Color
            {
                A = ColorComponents.A,
                R = ColorComponents.R,
                G = ColorComponents.G,
                B = ColorComponents.B
            };

            if (chart.View.DisableAnimations)
            {
                Rectangle.Fill = new SolidColorBrush(targetColor);
                return;
            }

            var animSpeed = chart.View.AnimationsSpeed;

            Rectangle.Fill.BeginAnimation(SolidColorBrush.ColorProperty,
                                          new ColorAnimation(targetColor, animSpeed));
        }
Example #8
0
        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);
            }

            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);
        }
Example #9
0
        internal IEnumerable <double> CalculateSeparatorIndices(ChartCore chart, AxisOrientation source, double unit)
        {
            if (!double.IsNaN(Separator.Step))
            {
                throw new Exception("Step should be NaN for WindowAxis separators");
            }
            if (Windows == null)
            {
                return(Enumerable.Empty <double>());
            }

            // Holder for the calculated separator indices and the proposed window
            var         supportedSeparatorCount = 0;
            var         separatorIndices        = new List <double>();
            IAxisWindow proposedWindow          = AxisWindows.EmptyWindow;

            // Build a range of possible separator indices
            var start        = (long)Math.Floor(BotLimit);
            var count        = (long)Math.Floor(TopLimit - (EvaluatesUnitWidth ? unit : 0.0) - BotLimit);
            var end          = start + count - 1;
            var rangeIndices = LongRange(start, end).Select(i => (double)i);//lol @ converting back to double WAT

            // Make sure we have at least 2 separators to show
            if (Windows != null && count > 1)
            {
                foreach (var window in Windows)
                {
                    IEnumerable <double> proposedSeparatorIndices;

                    // Calculate the number of supported separators.
                    supportedSeparatorCount = (int)Math.Floor(chart.ControlSize.Width / (window.MinimumSeparatorWidth * CleanFactor));

                    // Try go get separators. Continue if the window invalidated.
                    if (!window.TryGetSeparatorIndices(rangeIndices, supportedSeparatorCount, out proposedSeparatorIndices))
                    {
                        continue;
                    }

                    // Double check whether the window exceeded the maximum separator count.
                    // It might be it does not respect the supportedSeparatorCount parameter.
                    separatorIndices = proposedSeparatorIndices.ToList();
                    if (supportedSeparatorCount < separatorIndices.Count)
                    {
                        continue;
                    }

                    // Pick this window. It is the first who passed both validations and our best candidate
                    proposedWindow = window;
                    break;
                }
            }

            if (proposedWindow == null)
            {
                // All variables are still set to defaults
            }

            // Force the step of 1, as our prepare chart will filter the X axis for valid separators, and will skip a few
            S = 1;

            Magnitude      = Math.Pow(10, Math.Floor(Math.Log(supportedSeparatorCount) / Math.Log(10)));
            SelectedWindow = proposedWindow;

            return(separatorIndices);
        }
Example #10
0
        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);
            }

            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.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));
        }
Example #11
0
 public void Remove(ChartCore chart)
 {
     chart.View.RemoveFromDrawMargin(UIElement);
 }
Example #12
0
 public virtual void RemoveFromView(ChartCore chart)
 {
     throw new NotImplementedException();
 }
Example #13
0
 public virtual void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
 {
     throw new NotImplementedException();
 }
Example #14
0
        public void AddOrMove(ChartCore chart)
        {
            if (chart == null || UIElement == null)
            {
                return;
            }
            if (!chart.AreComponentsLoaded)
            {
                return;
            }

            if (UIElement.Parent == null)
            {
                chart.View.AddToDrawMargin(UIElement);
                Panel.SetZIndex(UIElement, 1000);
            }

            var coordinate = new CorePoint(ChartFunctions.ToDrawMargin(X, AxisOrientation.X, chart, AxisX),
                                           ChartFunctions.ToDrawMargin(Y, AxisOrientation.Y, chart.View.Model, AxisY));

            var wpfChart = (CartesianChart)chart.View;

            var uw = new CorePoint(
                wpfChart.AxisX[AxisX].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart, AxisX) / 2
                    : 0,
                wpfChart.AxisY[AxisY].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart, AxisY) / 2
                    : 0);

            coordinate += uw;

            UIElement.UpdateLayout();

            switch (VerticalAlignment)
            {
            case VerticalAlignment.Top:
                coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight);
                break;

            case VerticalAlignment.Center:
                coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight / 2);
                break;

            case VerticalAlignment.Bottom:
                coordinate = new CorePoint(coordinate.X, coordinate.Y);
                break;

            case VerticalAlignment.Stretch:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (HorizontalAlignment)
            {
            case HorizontalAlignment.Left:
                coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth, coordinate.Y);
                break;

            case HorizontalAlignment.Center:
                coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth / 2, coordinate.Y);
                break;

            case HorizontalAlignment.Right:
                coordinate = new CorePoint(coordinate.X, coordinate.Y);
                break;

            case HorizontalAlignment.Stretch:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (chart.View.DisableAnimations)
            {
                Canvas.SetLeft(UIElement, coordinate.X);
                Canvas.SetTop(UIElement, coordinate.Y);
            }
            else
            {
                if (double.IsNaN(Canvas.GetLeft(UIElement)))
                {
                    Canvas.SetLeft(UIElement, coordinate.X);
                    Canvas.SetTop(UIElement, coordinate.Y);
                }
                UIElement.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(coordinate.X, wpfChart.AnimationsSpeed));
                UIElement.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(coordinate.Y, wpfChart.AnimationsSpeed));
            }

            _owner = chart;
        }
Example #15
0
 public static double GetUnitWidth(AxisOrientation source, ChartCore chart, int axis = 0)
 {
     return(GetUnitWidth(source, chart,
                         (source == AxisOrientation.X ? chart.AxisX : chart.AxisY)[axis]));
 }
Example #16
0
        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(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.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;
            }
        }
Example #17
0
        /// <summary>
        /// Returns data in the chart according to:
        /// </summary>
        /// <param name="senderPoint">point that was hovered</param>
        /// <param name="chart">chart model to get the data from</param>
        /// <param name="selectionMode">selection mode</param>
        /// <returns></returns>
        public static TooltipDataViewModel GetTooltipData(ChartPoint senderPoint, ChartCore chart, TooltipSelectionMode selectionMode)
        {
            var ax = chart.AxisX[senderPoint.SeriesView.ScalesXAt];
            var ay = chart.AxisY[senderPoint.SeriesView.ScalesYAt];

            switch (selectionMode)
            {
            case TooltipSelectionMode.OnlySender:
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = new List <ChartPoint> {
                        senderPoint
                    },
                    Shares = null
                });

            case TooltipSelectionMode.SharedXValues:
                var tx = Math.Abs(FromPlotArea(1, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)
                                  - FromPlotArea(2, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)) * .01;
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = chart.View.ActualSeries.Where(x => x.ScalesXAt == senderPoint.SeriesView.ScalesXAt)
                             .SelectMany(x => x.Values.GetPoints(x))
                             .Where(x => Math.Abs(x.X - senderPoint.X) < tx),
                    Shares = (chart.View is IPieChart) ? null : (double?)senderPoint.X
                });

            case TooltipSelectionMode.SharedYValues:
                var ty = Math.Abs(FromPlotArea(1, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)
                                  - FromPlotArea(2, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)) * .01;
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = chart.View.ActualSeries.Where(x => x.ScalesYAt == senderPoint.SeriesView.ScalesYAt)
                             .SelectMany(x => x.Values.GetPoints(x))
                             .Where(x => Math.Abs(x.Y - senderPoint.Y) < ty),
                    Shares = senderPoint.Y
                });

            case TooltipSelectionMode.SharedXInSeries:
                var txs = Math.Abs(FromPlotArea(1, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)
                                   - FromPlotArea(2, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)) * .01;
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = senderPoint.SeriesView.ActualValues.GetPoints(senderPoint.SeriesView)
                             .Where(x => Math.Abs(x.X - senderPoint.X) < txs),
                    Shares = senderPoint.X
                });

            case TooltipSelectionMode.SharedYInSeries:
                var tys = Math.Abs(FromPlotArea(1, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)
                                   - FromPlotArea(2, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)) * .01;
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = senderPoint.SeriesView.ActualValues.GetPoints(senderPoint.SeriesView)
                             .Where(x => Math.Abs(x.Y - senderPoint.Y) < tys),
                    Shares = senderPoint.Y
                });

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #18
0
        public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
        {
            if (IsNew)
            {
                Slice.Width  = chart.DrawMargin.Width;
                Slice.Height = chart.DrawMargin.Height;

                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;

                hs.Width         = chart.DrawMargin.Width;
                hs.Height        = chart.DrawMargin.Height;
                hs.WedgeAngle    = Wedge;
                hs.RotationAngle = Rotation;
                hs.InnerRadius   = InnerRadius;
                hs.Radius        = Radius;
            }

            Slice.Width  = chart.DrawMargin.Width;
            Slice.Height = chart.DrawMargin.Height;

            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)
                {
                    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.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.CreateCanvasStoryBoardAndBegin(lx, ly, animSpeed);
            }

            Slice.BeginDoubleAnimation("(Canvas.Left)", chart.DrawMargin.Width / 2, animSpeed);
            Slice.BeginDoubleAnimation("(Canvas.Top)", chart.DrawMargin.Height / 2, animSpeed);
            Slice.BeginDoubleAnimation(nameof(PieSlice.InnerRadius), InnerRadius, animSpeed);
            Slice.BeginDoubleAnimation(nameof(PieSlice.Radius), Radius, animSpeed);
            Slice.BeginDoubleAnimation(nameof(PieSlice.WedgeAngle), Wedge, animSpeed);
            Slice.BeginDoubleAnimation(nameof(PieSlice.RotationAngle), Rotation, animSpeed);
        }
Example #19
0
        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 (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;
            }
        }
Example #20
0
 /// <summary>
 /// Removes the specified chart.
 /// </summary>
 /// <param name="chart">The chart.</param>
 public void Remove(ChartCore chart)
 {
     chart.View.RemoveFromView(UIElement);
 }
Example #21
0
        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.BeginAnimation(Line.X1Property,
                                        new DoubleAnimation(current.ChartLocation.X, animSpeed));
            VerticalLine.BeginAnimation(Line.X2Property,
                                        new DoubleAnimation(current.ChartLocation.X, animSpeed));
            VerticalLine.BeginAnimation(Line.Y1Property,
                                        new DoubleAnimation(current.ChartLocation.Y, animSpeed));
            VerticalLine.BeginAnimation(Line.Y2Property,
                                        new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));

            HorizontalLine.BeginAnimation(Line.X1Property,
                                          new DoubleAnimation(current.ChartLocation.X - DeltaX, animSpeed));
            HorizontalLine.BeginAnimation(Line.X2Property,
                                          new DoubleAnimation(current.ChartLocation.X, animSpeed));
            HorizontalLine.BeginAnimation(Line.Y1Property,
                                          new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));
            HorizontalLine.BeginAnimation(Line.Y2Property,
                                          new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));

            if (Shape != null)
            {
                Shape.BeginAnimation(Canvas.LeftProperty,
                                     new DoubleAnimation(current.ChartLocation.X - Shape.Width / 2, animSpeed));
                Shape.BeginAnimation(Canvas.TopProperty,
                                     new DoubleAnimation(current.ChartLocation.Y - Shape.Height / 2, animSpeed));
            }

            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);
            }
        }
Example #22
0
        /// <summary>
        /// Adds the or move.
        /// </summary>
        /// <param name="chart">The chart.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// </exception>
        public void AddOrMove(ChartCore chart)
        {
            if (chart?.AxisX == null || chart?.AxisY == null || UIElement == null)
            {
                return;
            }
            if (UIElement.Parent == null)
            {
                chart.View.AddToDrawMargin(UIElement);
                Canvas.SetZIndex(UIElement, 1000);
            }

            var coordinate = new CorePoint(ChartFunctions.ToDrawMargin(X, AxisOrientation.X, chart, AxisX),
                                           ChartFunctions.ToDrawMargin(Y, AxisOrientation.Y, chart, AxisY));

            var uwpChart = (CartesianChart)chart.View;

            var uw = new CorePoint(
                uwpChart.AxisX[AxisX].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart, AxisX) / 2
                    : 0,
                uwpChart.AxisY[AxisY].Model.EvaluatesUnitWidth
                    ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart, AxisY) / 2
                    : 0);

            coordinate += uw;

            UIElement.UpdateLayout();

            switch (VerticalAlignment)
            {
            case VerticalAlignment.Top:
                coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight);
                break;

            case VerticalAlignment.Center:
                coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight / 2);
                break;

            case VerticalAlignment.Bottom:
                coordinate = new CorePoint(coordinate.X, coordinate.Y);
                break;

            case VerticalAlignment.Stretch:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (HorizontalAlignment)
            {
            case HorizontalAlignment.Left:
                coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth, coordinate.Y);
                break;

            case HorizontalAlignment.Center:
                coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth / 2, coordinate.Y);
                break;

            case HorizontalAlignment.Right:
                coordinate = new CorePoint(coordinate.X, coordinate.Y);
                break;

            case HorizontalAlignment.Stretch:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (chart.View.DisableAnimations)
            {
                Canvas.SetLeft(UIElement, coordinate.X);
                Canvas.SetTop(UIElement, coordinate.Y);
            }
            else
            {
                if (double.IsNaN(Canvas.GetLeft(UIElement)))
                {
                    Canvas.SetLeft(UIElement, coordinate.X);
                    Canvas.SetTop(UIElement, coordinate.Y);
                }

                var x = AnimationsHelper.CreateDouble(coordinate.X, uwpChart.AnimationsSpeed, "(Canvas.Left)");
                var y = AnimationsHelper.CreateDouble(coordinate.Y, uwpChart.AnimationsSpeed, "(Canvas.Top)");
                AnimationsHelper.CreateStoryBoardAndBegin(UIElement, x, y);
            }
            _owner = chart;
        }
Example #23
0
        internal override CoreMargin PrepareChart(AxisOrientation source, ChartCore chart)
        {
            if (!(Math.Abs(TopLimit - BotLimit) > S * .01) || !ShowLabels)
            {
                return(new CoreMargin());
            }

            CalculateSeparator(chart, source);

            var f = GetFormatter();

            var currentMargin = new CoreMargin();

            if (S < 1)
            {
                S = 1;
            }
            var tolerance = S / 10;

            InitializeGarbageCollector();

            var bl    = Math.Ceiling(BotLimit / Magnitude) * Magnitude;
            var @base = ((ILogarithmicAxisView)View).Base;

            for (var i = bl; i <= TopLimit - (EvaluatesUnitWidth ? 1 : 0); i += S)
            {
                var minTolerance = tolerance / 10;
                if (Math.Abs(i - bl) > tolerance)
                {
                    var step = Math.Pow(@base, i - 1);
                    for (var j = Math.Pow(@base, i - 1) + step;
                         j < Math.Pow(@base, i);
                         j += step)
                    {
                        SeparatorElementCore minorAsc;
                        var scaledJ = Math.Log(j, @base);

                        var minorKey = Math.Round(scaledJ / minTolerance) * minTolerance;
                        if (!Cache.TryGetValue(minorKey, out minorAsc))
                        {
                            minorAsc = new SeparatorElementCore {
                                IsNew = true
                            };
                            Cache[minorKey] = minorAsc;
                        }
                        else
                        {
                            minorAsc.IsNew = false;
                        }

                        View.RenderSeparator(minorAsc, Chart);

                        minorAsc.Key   = minorKey;
                        minorAsc.Value = scaledJ;
                        minorAsc.GarbageCollectorIndex = GarbageCollectorIndex;

                        minorAsc.View.UpdateLabel(string.Empty, this, source);

                        if (LastAxisMax == null)
                        {
                            minorAsc.State = SeparationState.InitialAdd;
                            continue;
                        }

                        minorAsc.State = SeparationState.Keep;
                    }
                }

                SeparatorElementCore asc;

                var key = Math.Round(i / tolerance) * tolerance;
                if (!Cache.TryGetValue(key, out asc))
                {
                    asc = new SeparatorElementCore {
                        IsNew = true
                    };
                    Cache[key] = asc;
                }
                else
                {
                    asc.IsNew = false;
                }

                View.RenderSeparator(asc, Chart);

                asc.Key   = key;
                asc.Value = i;
                asc.GarbageCollectorIndex = GarbageCollectorIndex;

                var labelsMargin = asc.View.UpdateLabel(f(i), this, source);

                currentMargin.Width = labelsMargin.TakenWidth > currentMargin.Width
                    ? labelsMargin.TakenWidth
                    : currentMargin.Width;
                currentMargin.Height = labelsMargin.TakenHeight > currentMargin.Height
                    ? labelsMargin.TakenHeight
                    : currentMargin.Height;

                currentMargin.Left = labelsMargin.Left > currentMargin.Left
                    ? labelsMargin.Left
                    : currentMargin.Left;
                currentMargin.Right = labelsMargin.Right > currentMargin.Right
                    ? labelsMargin.Right
                    : currentMargin.Right;

                currentMargin.Top = labelsMargin.Top > currentMargin.Top
                    ? labelsMargin.Top
                    : currentMargin.Top;
                currentMargin.Bottom = labelsMargin.Bottom > currentMargin.Bottom
                    ? labelsMargin.Bottom
                    : currentMargin.Bottom;

                if (LastAxisMax == null)
                {
                    asc.State = SeparationState.InitialAdd;
                    continue;
                }

                asc.State = SeparationState.Keep;
            }
            return(currentMargin);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="AxisSectionCore" /> class.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="chart">The chart.</param>
 public AxisSectionCore(IAxisSectionView view, ChartCore chart)
 {
     View  = view;
     Chart = chart;
 }
Example #25
0
        internal CoreMargin PrepareChart(AxisOrientation source, ChartCore chart)
        {
            if (!(Math.Abs(TopLimit - BotLimit) > S * .01) || !ShowLabels)
            {
                return(new CoreMargin());
            }

            CalculateSeparator(chart, source);

            var f = GetFormatter();

            var currentMargin = new CoreMargin();
            var tolerance     = S / 10;

            InitializeGarbageCollector();

            var bl = Math.Ceiling(BotLimit / Magnitude) * Magnitude;

            for (var i = bl; i <= TopLimit - (EvaluatesUnitWidth ? 1 : 0); i += S)
            {
                SeparatorElementCore asc;

                var key = Math.Round(i / tolerance) * tolerance;
                if (!Cache.TryGetValue(key, out asc))
                {
                    asc = new SeparatorElementCore {
                        IsNew = true
                    };
                    Cache[key] = asc;
                }
                else
                {
                    asc.IsNew = false;
                }

                View.RenderSeparator(asc, Chart);

                asc.Key   = key;
                asc.Value = i;
                asc.GarbageCollectorIndex = GarbageCollectorIndex;

                var labelsMargin = asc.View.UpdateLabel(f(i), this, source);

                currentMargin.Width = labelsMargin.TakenWidth > currentMargin.Width
                    ? labelsMargin.TakenWidth
                    : currentMargin.Width;
                currentMargin.Height = labelsMargin.TakenHeight > currentMargin.Height
                    ? labelsMargin.TakenHeight
                    : currentMargin.Height;

                currentMargin.Left = labelsMargin.Left > currentMargin.Left
                    ? labelsMargin.Left
                    : currentMargin.Left;
                currentMargin.Right = labelsMargin.Right > currentMargin.Right
                    ? labelsMargin.Right
                    : currentMargin.Right;

                currentMargin.Top = labelsMargin.Top > currentMargin.Top
                    ? labelsMargin.Top
                    : currentMargin.Top;
                currentMargin.Bottom = labelsMargin.Bottom > currentMargin.Bottom
                    ? labelsMargin.Bottom
                    : currentMargin.Bottom;

                if (LastAxisMax == null)
                {
                    asc.State = SeparationState.InitialAdd;
                    continue;
                }

                asc.State = SeparationState.Keep;
            }
            return(currentMargin);
        }
Example #26
0
        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.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(PieSlice.WedgeAngleProperty, new DoubleAnimation(Wedge, animSpeed));
            Slice.BeginAnimation(PieSlice.RotationAngleProperty, new DoubleAnimation(Rotation, animSpeed));
        }
Example #27
0
        public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
        {
            var invertedMode = ((StepLineSeries)current.SeriesView).InvertedMode;

            if (IsNew)
            {
                if (invertedMode)
                {
                    Line1.X1 = current.ChartLocation.X;
                    Line1.X2 = current.ChartLocation.X - DeltaX;
                    Line1.Y1 = chart.DrawMargin.Height;
                    Line1.Y2 = chart.DrawMargin.Height;

                    Line2.X1 = current.ChartLocation.X - DeltaX;
                    Line2.X2 = current.ChartLocation.X - DeltaX;
                    Line2.Y1 = chart.DrawMargin.Height;
                    Line2.Y2 = chart.DrawMargin.Height;
                }
                else
                {
                    Line1.X1 = current.ChartLocation.X;
                    Line1.X2 = current.ChartLocation.X;
                    Line1.Y1 = chart.DrawMargin.Height;
                    Line1.Y2 = chart.DrawMargin.Height;

                    Line2.X1 = current.ChartLocation.X - DeltaX;
                    Line2.X2 = current.ChartLocation.X;
                    Line2.Y1 = chart.DrawMargin.Height;
                    Line2.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 && double.IsNaN(Canvas.GetLeft(DataLabel)))
            {
                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)
            {
                if (invertedMode)
                {
                    Line1.X1 = current.ChartLocation.X;
                    Line1.X2 = current.ChartLocation.X - DeltaX;
                    Line1.Y1 = current.ChartLocation.Y;
                    Line1.Y2 = current.ChartLocation.Y;

                    Line2.X1 = current.ChartLocation.X - DeltaX;
                    Line2.X2 = current.ChartLocation.X - DeltaX;
                    Line2.Y1 = current.ChartLocation.Y;
                    Line2.Y2 = current.ChartLocation.Y - DeltaY;
                }
                else
                {
                    Line1.X1 = current.ChartLocation.X;
                    Line1.X2 = current.ChartLocation.X;
                    Line1.Y1 = current.ChartLocation.Y;
                    Line1.Y2 = current.ChartLocation.Y - DeltaY;

                    Line2.X1 = current.ChartLocation.X - DeltaX;
                    Line2.X2 = current.ChartLocation.X;
                    Line2.Y1 = current.ChartLocation.Y - DeltaY;
                    Line2.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;

            if (invertedMode)
            {
                Line1.BeginAnimation(Line.X1Property,
                                     new DoubleAnimation(current.ChartLocation.X, animSpeed));
                Line1.BeginAnimation(Line.X2Property,
                                     new DoubleAnimation(current.ChartLocation.X - DeltaX, animSpeed));
                Line1.BeginAnimation(Line.Y1Property,
                                     new DoubleAnimation(current.ChartLocation.Y, animSpeed));
                Line1.BeginAnimation(Line.Y2Property,
                                     new DoubleAnimation(current.ChartLocation.Y, animSpeed));

                Line2.BeginAnimation(Line.X1Property,
                                     new DoubleAnimation(current.ChartLocation.X - DeltaX, animSpeed));
                Line2.BeginAnimation(Line.X2Property,
                                     new DoubleAnimation(current.ChartLocation.X - DeltaX, animSpeed));
                Line2.BeginAnimation(Line.Y1Property,
                                     new DoubleAnimation(current.ChartLocation.Y, animSpeed));
                Line2.BeginAnimation(Line.Y2Property,
                                     new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));
            }
            else
            {
                Line1.BeginAnimation(Line.X1Property,
                                     new DoubleAnimation(current.ChartLocation.X, animSpeed));
                Line1.BeginAnimation(Line.X2Property,
                                     new DoubleAnimation(current.ChartLocation.X, animSpeed));
                Line1.BeginAnimation(Line.Y1Property,
                                     new DoubleAnimation(current.ChartLocation.Y, animSpeed));
                Line1.BeginAnimation(Line.Y2Property,
                                     new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));

                Line2.BeginAnimation(Line.X1Property,
                                     new DoubleAnimation(current.ChartLocation.X - DeltaX, animSpeed));
                Line2.BeginAnimation(Line.X2Property,
                                     new DoubleAnimation(current.ChartLocation.X, animSpeed));
                Line2.BeginAnimation(Line.Y1Property,
                                     new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));
                Line2.BeginAnimation(Line.Y2Property,
                                     new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));
            }

            if (Shape != null)
            {
                Shape.BeginAnimation(Canvas.LeftProperty,
                                     new DoubleAnimation(current.ChartLocation.X - Shape.Width / 2, animSpeed));
                Shape.BeginAnimation(Canvas.TopProperty,
                                     new DoubleAnimation(current.ChartLocation.Y - Shape.Height / 2, animSpeed));
            }

            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);
            }
        }
Example #28
0
 /// <summary>
 /// Converts from chart values to chart draw margin size.
 /// </summary>
 /// <param name="point">point to scale</param>
 /// <param name="axisXIndex">axis orientation</param>
 /// <param name="axisYIndex">axis instance to scale the value at</param>
 /// <param name="chart">chart model to scale the value at</param>
 /// <returns></returns>
 public static CorePoint ToDrawMargin(ChartPoint point, int axisXIndex, int axisYIndex, ChartCore chart)
 {
     return(new CorePoint(
                ToDrawMargin(point.X, AxisOrientation.X, chart, axisXIndex),
                ToDrawMargin(point.Y, AxisOrientation.Y, chart, axisYIndex)));
 }
        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 : (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);
            }
        }