/// <summary> /// Gets the view of a given point /// </summary> /// <param name="point"></param> /// <param name="label"></param> /// <returns></returns> public override IChartPointView GetPointView(ChartPoint point, string label) { var pbv = (PiePointView) point.View; if (pbv == null) { pbv = new PiePointView { IsNew = true, Slice = new PieSlice() }; Model.Chart.View.AddToDrawMargin(pbv.Slice); } else { pbv.IsNew = false; point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.Slice); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel); } pbv.Slice.Fill = Fill; pbv.Slice.Stroke = Stroke; pbv.Slice.StrokeThickness = StrokeThickness; pbv.Slice.StrokeDashArray = StrokeDashArray; pbv.Slice.PushOut = PushOut; pbv.Slice.Visibility = Visibility; Panel.SetZIndex(pbv.Slice, Panel.GetZIndex(this)); if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null) { pbv.HoverShape = new PieSlice { Fill = Brushes.Transparent, StrokeThickness = 0 }; Panel.SetZIndex(pbv.HoverShape, int.MaxValue); var wpfChart = (Chart)Model.Chart.View; wpfChart.AttachHoverableEventTo(pbv.HoverShape); Model.Chart.View.AddToDrawMargin(pbv.HoverShape); } if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility; if (DataLabels && pbv.DataLabel == null) { pbv.DataLabel = BindATextBlock(0); Panel.SetZIndex(pbv.DataLabel, int.MaxValue - 1); Model.Chart.View.AddToDrawMargin(pbv.DataLabel); } if (pbv.DataLabel != null) pbv.DataLabel.Text = label; pbv.OriginalPushOut = PushOut; return pbv; }
public override IChartPointView GetPointView(IChartPointView view, ChartPoint point, string label) { var pbv = (view as PiePointView); if (pbv == null) { pbv = new PiePointView { IsNew = true, Slice = new PieSlice() }; BindingOperations.SetBinding(pbv.Slice, Shape.FillProperty, new Binding { Path = new PropertyPath(FillProperty), Source = this }); BindingOperations.SetBinding(pbv.Slice, Shape.StrokeProperty, new Binding { Path = new PropertyPath(StrokeProperty), Source = this }); BindingOperations.SetBinding(pbv.Slice, Shape.StrokeThicknessProperty, new Binding {Path = new PropertyPath(StrokeThicknessProperty), Source = this}); BindingOperations.SetBinding(pbv.Slice, Shape.StrokeDashArrayProperty, new Binding {Path = new PropertyPath(StrokeDashArrayProperty), Source = this}); BindingOperations.SetBinding(pbv.Slice, PieSlice.PushOutProperty, new Binding {Path = new PropertyPath(PushOutProperty), Source = this}); BindingOperations.SetBinding(pbv.Slice, Panel.ZIndexProperty, new Binding {Path = new PropertyPath(Panel.ZIndexProperty), Source = this}); BindingOperations.SetBinding(pbv.Slice, VisibilityProperty, new Binding {Path = new PropertyPath(VisibilityProperty), Source = this}); Model.Chart.View.AddToDrawMargin(pbv.Slice); } else { pbv.IsNew = false; point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.Slice); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel); } if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null) { pbv.HoverShape = new PieSlice { Fill = Brushes.Transparent, StrokeThickness = 0 }; Panel.SetZIndex(pbv.HoverShape, int.MaxValue); BindingOperations.SetBinding(pbv.HoverShape, VisibilityProperty, new Binding {Path = new PropertyPath(VisibilityProperty), Source = this}); var wpfChart = (Chart)Model.Chart.View; wpfChart.AttachHoverableEventTo(pbv.HoverShape); Model.Chart.View.AddToDrawMargin(pbv.HoverShape); } if (DataLabels && pbv.DataLabel == null) { pbv.DataLabel = BindATextBlock(0); Panel.SetZIndex(pbv.DataLabel, int.MaxValue - 1); Model.Chart.View.AddToDrawMargin(pbv.DataLabel); } if (pbv.DataLabel != null) pbv.DataLabel.Text = label; return pbv; }