/// <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 = UpdateLabelContent(new DataLabelViewModel { FormattedText = label, Point = point }, pbv.DataLabel); } if (!DataLabels && pbv.DataLabel != null) { Model.Chart.View.RemoveFromDrawMargin(pbv.DataLabel); pbv.DataLabel = null; } if (point.Stroke != null) { pbv.Slice.Stroke = (Brush)point.Stroke; } if (point.Fill != null) { pbv.Slice.Fill = (Brush)point.Fill; } 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); }
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; } if ((Model.Chart.View.HasTooltip || Model.Chart.View.HasDataClickEventAttached) && 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 = Model.Chart.View as Chart; if (wpfChart == null) { return(null); } wpfChart.AttachEventsTo(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); }
/// <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; Canvas.SetZIndex(pbv.Slice, Canvas.GetZIndex(this)); if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null) { pbv.HoverShape = new PieSlice { Fill = new SolidColorBrush(Windows.UI.Colors.Transparent), StrokeThickness = 0 }; Canvas.SetZIndex(pbv.HoverShape, short.MaxValue); var uwpfChart = (Chart)Model.Chart.View; uwpfChart.AttachHoverableEventTo(pbv.HoverShape); Model.Chart.View.AddToDrawMargin(pbv.HoverShape); } if (pbv.HoverShape != null) { pbv.HoverShape.Visibility = Visibility; } if (DataLabels && pbv.DataLabel == null) { pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel { FormattedText = label, Instance = point.Instance }); Canvas.SetZIndex(pbv.DataLabel, short.MaxValue - 1); Model.Chart.View.AddToDrawMargin(pbv.DataLabel); } pbv.OriginalPushOut = PushOut; return(pbv); }