Exemplo n.º 1
0
 public override void OnHoverLeave(ChartPoint point)
 {
     if (point.Fill != null)
     {
         Slice.Fill = (Brush)point.Fill;
     }
     else
     {
         Slice.Fill = ((Series)point.SeriesView).Fill;
     }
     Slice.BeginDoubleAnimation(nameof(Slice.PushOut), OriginalPushOut,
                                point.SeriesView.Model.Chart.View.AnimationsSpeed);
 }
Exemplo n.º 2
0
        public override void OnHover(ChartPoint point)
        {
            Slice.Fill = Slice.Fill.Clone();

            if (Slice?.Fill != null)
            {
                Slice.Fill.Opacity -= .15;
            }

            if (Slice != null)
            {
                var pieChart = (PieChart)point.SeriesView.Model.Chart.View;

                Slice.BeginDoubleAnimation(nameof(PieSlice.PushOut), Slice.PushOut,
                                           OriginalPushOut + pieChart.HoverPushOut,
                                           point.SeriesView.Model.Chart.View.AnimationsSpeed);
            }
        }
Exemplo n.º 3
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, 0d);
                Canvas.SetLeft(DataLabel, 0d);
            }

            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;

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

            Slice.BeginDoubleAnimation(nameof(PieSlice.WedgeAngle), Wedge, animSpeed);
            Slice.BeginDoubleAnimation(nameof(PieSlice.RotationAngle), Rotation, animSpeed);
        }