示例#1
0
        /// <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 mhr = PointGeometrySize < 10 ? 10 : PointGeometrySize;

            var pbv = (HorizontalBezierPointView)point.View;

            if (pbv == null)
            {
                pbv = new HorizontalBezierPointView
                {
                    Segment   = new BezierSegment(),
                    Container = Figure,
                    IsNew     = true
                };
            }
            else
            {
                pbv.IsNew = false;
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.Shape);
                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,
                    Width           = mhr,
                    Height          = mhr
                };

                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 (PointGeometry != null && Math.Abs(PointGeometrySize) > 0.1 && pbv.Shape == null)
            {
                if (PointGeometry != null)
                {
                    pbv.Shape = new Path
                    {
                        Stretch         = Stretch.Fill,
                        StrokeThickness = StrokeThickness
                    };
                }

                Model.Chart.View.AddToDrawMargin(pbv.Shape);
            }

            if (pbv.Shape != null)
            {
                pbv.Shape.Fill            = PointForeround;
                pbv.Shape.Stroke          = Stroke;
                pbv.Shape.StrokeThickness = StrokeThickness;
                pbv.Shape.Width           = PointGeometrySize;
                pbv.Shape.Height          = PointGeometrySize;
                pbv.Shape.Data            = PointGeometry;
                pbv.Shape.Visibility      = Visibility;
                Panel.SetZIndex(pbv.Shape, Panel.GetZIndex(this) + 1);

                if (point.Stroke != null)
                {
                    pbv.Shape.Stroke = (Brush)point.Stroke;
                }
                if (point.Fill != null)
                {
                    pbv.Shape.Fill = (Brush)point.Fill;
                }
            }

            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 mhr = PointGeometrySize < 10 ? 10 : PointGeometrySize;

            var pbv = (HorizontalBezierPointView)point.View;

            if (pbv == null)
            {
                pbv = new HorizontalBezierPointView
                {
                    Segment   = new BezierSegment(),
                    Container = Figure,
                    IsNew     = true
                };
            }
            else
            {
                pbv.IsNew = false;
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.Shape);
                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            = new SolidColorBrush(Windows.UI.Colors.Transparent),
                    StrokeThickness = 0,
                    Width           = mhr,
                    Height          = mhr
                };

                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 (Math.Abs(PointGeometrySize) > 0.1 && pbv.Shape == null)
            {
                pbv.Shape = new Path
                {
                    Stretch         = Stretch.Fill,
                    StrokeThickness = StrokeThickness
                };

                Model.Chart.View.AddToDrawMargin(pbv.Shape);
            }

            if (pbv.Shape != null)
            {
                pbv.Shape.Fill            = PointForeround;
                pbv.Shape.Stroke          = Stroke;
                pbv.Shape.StrokeThickness = StrokeThickness;
                pbv.Shape.Width           = PointGeometrySize;
                pbv.Shape.Height          = PointGeometrySize;
                pbv.Shape.Data            = PointGeometry.Parse();
                pbv.Shape.Visibility      = Visibility;
                Canvas.SetZIndex(pbv.Shape, Canvas.GetZIndex(this) + 1);

                if (point.Stroke != null)
                {
                    pbv.Shape.Stroke = (Brush)point.Stroke;
                }
                if (point.Fill != null)
                {
                    pbv.Shape.Fill = (Brush)point.Fill;
                }
            }

            if (DataLabels)
            {
                pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
                {
                    FormattedText = label,
                    Instance      = point.Instance
                }, pbv.DataLabel);
            }

            return(pbv);
        }