Exemplo n.º 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 pbv = (ScatterPointView)point.View;

            if (pbv == null)
            {
                pbv = new ScatterPointView
                {
                    IsNew = true,
                    Shape = new Path
                    {
                        Stretch         = Stretch.Fill,
                        StrokeThickness = StrokeThickness
                    }
                };

                Model.Chart.View.AddToDrawMargin(pbv.Shape);
            }
            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);
            }

            var p = (Path)pbv.Shape;

            p.Data            = PointGeometry;
            p.Fill            = Fill;
            p.Stroke          = Stroke;
            p.StrokeThickness = StrokeThickness;
            p.Visibility      = Visibility;
            Panel.SetZIndex(p, Panel.GetZIndex(this));
            p.StrokeDashArray = StrokeDashArray;

            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 == null)
            {
                pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
                {
                    FormattedText = label,
                    Instance      = point.Instance
                });
                Panel.SetZIndex(pbv.DataLabel, int.MaxValue - 1);

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

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

            return(pbv);
        }
Exemplo 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 pbv = (ScatterPointView)point.View;

            if (pbv == null)
            {
                pbv = new ScatterPointView
                {
                    IsNew = true,
                    Shape = new Path
                    {
                        Stretch         = Stretch.Fill,
                        StrokeThickness = StrokeThickness
                    }
                };

                Model.Chart.View.AddToDrawMargin(pbv.Shape);
            }
            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);
            }

            var p = (Path)pbv.Shape;

            p.Data            = PointGeometry.Parse();
            p.Fill            = Fill;
            p.Stroke          = Stroke;
            p.StrokeThickness = StrokeThickness;
            p.Visibility      = Visibility;
            Canvas.SetZIndex(p, Canvas.GetZIndex(this));
            p.StrokeDashArray = StrokeDashArray;

            if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
            {
                pbv.HoverShape = new Rectangle
                {
                    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 = 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.Stroke != null)
            {
                pbv.Shape.Stroke = (Brush)point.Stroke;
            }
            if (point.Fill != null)
            {
                pbv.Shape.Fill = (Brush)point.Fill;
            }

            return(pbv);
        }
Exemplo n.º 3
0
        public override IChartPointView GetPointView(IChartPointView view, ChartPoint point, string label)
        {
            var pbv = (view as ScatterPointView);

            if (pbv == null)
            {
                pbv = new ScatterPointView
                {
                    IsNew = true,
                    Shape = new Path
                    {
                        Stretch         = Stretch.Fill,
                        ClipToBounds    = true,
                        StrokeThickness = StrokeThickness
                    }
                };
                BindingOperations.SetBinding(pbv.Shape, Path.DataProperty,
                                             new Binding {
                    Path = new PropertyPath(PointGeometryProperty), Source = this
                });

                BindingOperations.SetBinding(pbv.Shape, Shape.FillProperty,
                                             new Binding {
                    Path = new PropertyPath(FillProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Shape, Shape.StrokeProperty,
                                             new Binding {
                    Path = new PropertyPath(StrokeProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Shape, Shape.StrokeThicknessProperty,
                                             new Binding {
                    Path = new PropertyPath(StrokeThicknessProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Shape, VisibilityProperty,
                                             new Binding {
                    Path = new PropertyPath(VisibilityProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Shape, Panel.ZIndexProperty,
                                             new Binding {
                    Path = new PropertyPath(Panel.ZIndexProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Shape, Shape.StrokeDashArrayProperty,
                                             new Binding {
                    Path = new PropertyPath(StrokeDashArrayProperty), Source = this
                });

                Model.Chart.View.AddToDrawMargin(pbv.Shape);
            }
            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
                };

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

            return(pbv);
        }