Ejemplo n.º 1
0
        /// <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 mhr = PointGeometrySize < 10 ? 10 : PointGeometrySize;

            var pbv = (VerticalBezierPointView)point.View;

            if (pbv == null)
            {
                pbv = new VerticalBezierPointView
                {
                    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 == 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;
            }

            return(pbv);
        }
Ejemplo n.º 2
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 = (VerticalBezierPointView)point.View;

            if (pbv == null)
            {
                pbv = new VerticalBezierPointView
                {
                    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            = PointForeground;
                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 = UpdateLabelContent(new DataLabelViewModel
                {
                    FormattedText = label,
                    Point         = point
                }, pbv.DataLabel);
            }

            if (!DataLabels && pbv.DataLabel != null)
            {
                Model.Chart.View.RemoveFromDrawMargin(pbv.DataLabel);
                pbv.DataLabel = null;
            }

            return(pbv);
        }
Ejemplo n.º 3
0
        public override IChartPointView GetPointView(IChartPointView view, ChartPoint point, string label)
        {
            var mhr = PointGeometrySize < 10 ? 10 : PointGeometrySize;

            var pbv = (VerticalBezierPointView)view;

            if (pbv == null)
            {
                pbv = new VerticalBezierPointView
                {
                    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.View.HasTooltip || Model.Chart.View.HasDataClickEventAttached) && 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,
                        ClipToBounds    = true,
                        StrokeThickness = StrokeThickness
                    };
                }

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

            if (pbv.Shape != null)
            {
                pbv.Shape.Fill            = Fill;
                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);
        }