/// <summary> /// Gets the point view. /// </summary> /// <param name="point">The point.</param> /// <param name="label">The label.</param> /// <returns></returns> public override IChartPointView GetPointView(ChartPoint point, string label) { var pbv = (CandlePointView)point.View; if (pbv == null) { pbv = new CandlePointView { IsNew = true, HighToLowLine = new Line(), OpenToCloseRectangle = new Rectangle() }; Model.Chart.View.AddToDrawMargin(pbv.HighToLowLine); Model.Chart.View.AddToDrawMargin(pbv.OpenToCloseRectangle); } else { pbv.IsNew = false; point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.HighToLowLine); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.OpenToCloseRectangle); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel); } var i = Panel.GetZIndex(this); pbv.HighToLowLine.StrokeThickness = StrokeThickness; pbv.HighToLowLine.StrokeDashArray = StrokeDashArray; pbv.HighToLowLine.Visibility = Visibility; Panel.SetZIndex(pbv.HighToLowLine, i); pbv.OpenToCloseRectangle.Fill = Fill; pbv.OpenToCloseRectangle.StrokeThickness = StrokeThickness; pbv.OpenToCloseRectangle.Stroke = Stroke; pbv.OpenToCloseRectangle.StrokeDashArray = StrokeDashArray; pbv.OpenToCloseRectangle.Visibility = Visibility; Panel.SetZIndex(pbv.HighToLowLine, i); if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null) { pbv.HoverShape = new Rectangle { 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, Instance = point.Instance }, pbv.DataLabel); } return(pbv); }
public override IChartPointView GetPointView(ChartPoint point, string label) { var pbv = (CandlePointView)point.View; if (pbv == null) { pbv = new CandlePointView { IsNew = true, HighToLowLine = new Line(), OpenToCloseRectangle = new Rectangle() }; Model.Chart.View.AddToDrawMargin(pbv.HighToLowLine); Model.Chart.View.AddToDrawMargin(pbv.OpenToCloseRectangle); } else { pbv.IsNew = false; point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.HighToLowLine); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.OpenToCloseRectangle); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel); } var i = Canvas.GetZIndex(this); pbv.HighToLowLine.StrokeThickness = StrokeThickness; pbv.HighToLowLine.StrokeDashArray = StrokeDashArray; pbv.HighToLowLine.Visibility = Visibility; Canvas.SetZIndex(pbv.HighToLowLine, i); pbv.OpenToCloseRectangle.Fill = Fill; pbv.OpenToCloseRectangle.StrokeThickness = StrokeThickness; pbv.OpenToCloseRectangle.Stroke = Stroke; pbv.OpenToCloseRectangle.StrokeDashArray = StrokeDashArray; pbv.OpenToCloseRectangle.Visibility = Visibility; Canvas.SetZIndex(pbv.HighToLowLine, i); if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null) { pbv.HoverShape = new Rectangle { Fill = new SolidColorBrush(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 = BindATextBlock(0); Canvas.SetZIndex(pbv.DataLabel, short.MaxValue - 1); Model.Chart.View.AddToDrawMargin(pbv.DataLabel); } if (pbv.DataLabel != null) { pbv.DataLabel.Text = label; } if (point.Open <= point.Close) { pbv.HighToLowLine.Stroke = IncreaseBrush; pbv.OpenToCloseRectangle.Fill = IncreaseBrush; pbv.OpenToCloseRectangle.Stroke = IncreaseBrush; } else { pbv.HighToLowLine.Stroke = DecreaseBrush; pbv.OpenToCloseRectangle.Fill = DecreaseBrush; pbv.OpenToCloseRectangle.Stroke = DecreaseBrush; } return(pbv); }
public override IChartPointView GetPointView(IChartPointView view, ChartPoint point, string label) { var pbv = (view as CandlePointView); if (pbv == null) { pbv = new CandlePointView { IsNew = true, HighToLowLine = new Line(), OpenToCloseRectangle = new Rectangle() }; BindingOperations.SetBinding(pbv.HighToLowLine, Shape.StrokeThicknessProperty, new Binding { Path = new PropertyPath(StrokeThicknessProperty), Source = this }); BindingOperations.SetBinding(pbv.HighToLowLine, Shape.StrokeDashArrayProperty, new Binding { Path = new PropertyPath(StrokeDashArrayProperty), Source = this }); BindingOperations.SetBinding(pbv.HighToLowLine, Panel.ZIndexProperty, new Binding { Path = new PropertyPath(Panel.ZIndexProperty), Source = this }); BindingOperations.SetBinding(pbv.HighToLowLine, VisibilityProperty, new Binding { Path = new PropertyPath(VisibilityProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, Shape.FillProperty, new Binding { Path = new PropertyPath(FillProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, Shape.StrokeProperty, new Binding { Path = new PropertyPath(StrokeProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, Shape.StrokeThicknessProperty, new Binding { Path = new PropertyPath(StrokeThicknessProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, Shape.StrokeDashArrayProperty, new Binding { Path = new PropertyPath(StrokeDashArrayProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, Panel.ZIndexProperty, new Binding { Path = new PropertyPath(Panel.ZIndexProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, VisibilityProperty, new Binding { Path = new PropertyPath(VisibilityProperty), Source = this }); Model.Chart.View.AddToDrawMargin(pbv.HighToLowLine); Model.Chart.View.AddToDrawMargin(pbv.OpenToCloseRectangle); } else { pbv.IsNew = false; point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.HighToLowLine); point.SeriesView.Model.Chart.View .EnsureElementBelongsToCurrentDrawMargin(pbv.OpenToCloseRectangle); 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 Rectangle { 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; } if (point.Open <= point.Close) { BindingOperations.SetBinding(pbv.HighToLowLine, Shape.StrokeProperty, new Binding { Path = new PropertyPath(IncreaseBrushProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, Shape.StrokeProperty, new Binding { Path = new PropertyPath(IncreaseBrushProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, Shape.FillProperty, new Binding { Path = new PropertyPath(IncreaseBrushProperty), Source = this }); } else { BindingOperations.SetBinding(pbv.HighToLowLine, Shape.StrokeProperty, new Binding { Path = new PropertyPath(DecreaseBrushProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, Shape.StrokeProperty, new Binding { Path = new PropertyPath(DecreaseBrushProperty), Source = this }); BindingOperations.SetBinding(pbv.OpenToCloseRectangle, Shape.FillProperty, new Binding { Path = new PropertyPath(DecreaseBrushProperty), Source = this }); } return(pbv); }