protected internal override void DataMouseLeave(object sender, MouseEventArgs e) { base.DataMouseLeave(sender, e); var senderShape = ShapesMapper.FirstOrDefault(s => Equals(s.HoverShape, sender)); var pieSlice = senderShape != null ? senderShape.HoverShape as PieSlice : null; if (pieSlice == null) { return; } pieSlice.Opacity = 1; var anim = new DoubleAnimation { To = 0, Duration = TimeSpan.FromMilliseconds(150) }; pieSlice.BeginAnimation(PieSlice.PushOutProperty, anim); }
protected internal override void DataMouseEnter(object sender, MouseEventArgs e) { if (DataTooltip == null || !Hoverable) { return; } DataTooltip.Visibility = Visibility.Visible; TooltipTimer.Stop(); var senderShape = ShapesMapper.FirstOrDefault(s => Equals(s.HoverShape, sender)); if (senderShape == null) { return; } var pieSlice = senderShape.HoverShape as PieSlice; if (pieSlice == null) { return; } var xi = senderShape.Series.ScalesXAt; var yi = senderShape.Series.ScalesYAt; var labels = AxisX[xi].Labels != null ? AxisX[xi].Labels.ToArray() : null; senderShape.Shape.Opacity = .8; var vx = senderShape.ChartPoint.X; var indexedToolTip = DataTooltip as IndexedTooltip; if (indexedToolTip != null) { indexedToolTip.Header = null; //labels == null // ? (AxisX.LabelFormatter == null // ? vx.ToString(CultureInfo.InvariantCulture) // : AxisX.LabelFormatter(vx)) // : (labels.Length > vx // ? labels[(int)vx] // : ""); indexedToolTip.Data = new[] { new IndexedTooltipData { Index = (int)vx, Stroke = senderShape.HoverShape.Stroke, Fill = senderShape.HoverShape.Fill, Series = senderShape.Series, Point = senderShape.ChartPoint, Value = AxisY[yi].LabelFormatter == null ? senderShape.ChartPoint.Y.ToString(CultureInfo.InvariantCulture) : AxisY[yi].LabelFormatter(senderShape.ChartPoint.Y) } }; } var alpha = pieSlice.RotationAngle + pieSlice.WedgeAngle * .5 + 180; var alphaRad = alpha * Math.PI / 180; var sliceMidAngle = alpha - 180; DataTooltip.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var y = Canvas.ActualHeight * .5 + (sliceMidAngle > 90 && sliceMidAngle < 270 ? -1 : 0) * DataTooltip.DesiredSize.Height - Math.Cos(alphaRad) * 15; var x = Canvas.ActualWidth * .5 + (sliceMidAngle > 0 && sliceMidAngle < 180 ? -1 : 0) * DataTooltip.DesiredSize.Width + Math.Sin(alphaRad) * 15; var p = new Point(x, y); DataTooltip.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation { To = p.X, Duration = TimeSpan.FromMilliseconds(200) }); DataTooltip.BeginAnimation(Canvas.TopProperty, new DoubleAnimation { To = p.Y, Duration = TimeSpan.FromMilliseconds(200) }); pieSlice.Opacity = .8; var anim = new DoubleAnimation { To = 5, Duration = TimeSpan.FromMilliseconds(150) }; pieSlice.BeginAnimation(PieSlice.PushOutProperty, anim); }