Exemplo n.º 1
0
        public override IChartPointView GetPointView(IChartPointView view, ChartPoint point, string label)
        {
            var mhr = PointDiameter < 10 ? 10 : PointDiameter;

            var pbv = (view as HBezierPointView);

            if (pbv == null)
            {
                pbv = new HBezierPointView
                {
                    Segment   = new BezierSegment(),
                    Container = Figure,
                    IsNew     = true
                };
            }
            else
            {
                pbv.IsNew = false;
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.Ellipse);
                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);
                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 (Math.Abs(PointDiameter) > 0.1 && pbv.Ellipse == null)
            {
                pbv.Ellipse = new Ellipse();

                BindingOperations.SetBinding(pbv.Ellipse, Shape.FillProperty,
                                             new Binding {
                    Path = new PropertyPath(PointForeroundProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Ellipse, Shape.StrokeProperty,
                                             new Binding {
                    Path = new PropertyPath(StrokeProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Ellipse, Shape.StrokeThicknessProperty,
                                             new Binding {
                    Path = new PropertyPath(StrokeThicknessProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Ellipse, WidthProperty,
                                             new Binding {
                    Path = new PropertyPath(PointDiameterProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Ellipse, HeightProperty,
                                             new Binding {
                    Path = new PropertyPath(PointDiameterProperty), Source = this
                });

                BindingOperations.SetBinding(pbv.Ellipse, VisibilityProperty,
                                             new Binding {
                    Path = new PropertyPath(VisibilityProperty), Source = this
                });

                Panel.SetZIndex(pbv.Ellipse, int.MaxValue - 2);

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

            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);
        }
Exemplo n.º 2
0
        public override IChartPointView GetPointView(IChartPointView view, ChartPoint point, string label)
        {
            var mhr = PointGeometrySize < 10 ? 10 : PointGeometrySize;

            var pbv = (HBezierPointView)view;

            if (pbv == null)
            {
                pbv = new HBezierPointView
                {
                    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);
                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 (PointGeometry != null && Math.Abs(PointGeometrySize) > 0.1 && pbv.Shape == null)
            {
                if (PointGeometry != null)
                {
                    pbv.Shape = new Path
                    {
                        Stretch         = Stretch.Fill,
                        ClipToBounds    = true,
                        StrokeThickness = StrokeThickness
                    };
                    BindingOperations.SetBinding(pbv.Shape, Path.DataProperty,
                                                 new Binding {
                        Path = new PropertyPath(PointGeometryProperty), Source = this
                    });
                }
                else
                {
                    pbv.Shape = new Ellipse();
                }

                BindingOperations.SetBinding(pbv.Shape, Shape.FillProperty,
                                             new Binding {
                    Path = new PropertyPath(PointForeroundProperty), 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, WidthProperty,
                                             new Binding {
                    Path = new PropertyPath(PointGeometrySizeProperty), Source = this
                });
                BindingOperations.SetBinding(pbv.Shape, HeightProperty,
                                             new Binding {
                    Path = new PropertyPath(PointGeometrySizeProperty), Source = this
                });

                BindingOperations.SetBinding(pbv.Shape, VisibilityProperty,
                                             new Binding {
                    Path = new PropertyPath(VisibilityProperty), Source = this
                });

                Panel.SetZIndex(pbv.Shape, int.MaxValue - 2);

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

            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);
        }