示例#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 = (StepLinePointView)point.View;

            if (pbv == null)
            {
                pbv = new StepLinePointView
                {
                    IsNew          = true,
                    HorizontalLine = new Line(),
                    VerticalLine   = new Line()
                };

                Model.Chart.View.AddToDrawMargin(pbv.HorizontalLine);
                Model.Chart.View.AddToDrawMargin(pbv.VerticalLine);
                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);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.HorizontalLine);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.VerticalLine);
            }

            pbv.VerticalLine.StrokeThickness = StrokeThickness;
            pbv.VerticalLine.Stroke          = AlternativeStroke;
            pbv.VerticalLine.StrokeDashArray = StrokeDashArray;
            pbv.VerticalLine.Visibility      = Visibility;
            Panel.SetZIndex(pbv.VerticalLine, Panel.GetZIndex(this));

            pbv.HorizontalLine.StrokeThickness = StrokeThickness;
            pbv.HorizontalLine.Stroke          = Stroke;
            pbv.HorizontalLine.StrokeDashArray = StrokeDashArray;
            pbv.HorizontalLine.Visibility      = Visibility;
            Panel.SetZIndex(pbv.HorizontalLine, Panel.GetZIndex(this));

            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.StrokeThickness = StrokeThickness;
                pbv.Shape.Stroke          = Stroke;
                pbv.Shape.StrokeDashArray = StrokeDashArray;
                pbv.Shape.Visibility      = Visibility;
                pbv.Shape.Width           = PointGeometrySize;
                pbv.Shape.Height          = PointGeometrySize;
                pbv.Shape.Data            = PointGeometry;
                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 (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);
        }
示例#2
0
        public override IChartPointView GetPointView(IChartPointView view, ChartPoint point, string label)
        {
            var pbv = (view as StepLinePointView);

            if (pbv == null)
            {
                pbv = new StepLinePointView
                {
                    IsNew          = true,
                    HorizontalLine = new Line(),
                    VerticalLine   = new Line()
                };

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

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

                Model.Chart.View.AddToDrawMargin(pbv.HorizontalLine);
                Model.Chart.View.AddToDrawMargin(pbv.VerticalLine);
                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);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.HorizontalLine);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.VerticalLine);
            }

            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
                });
                BindingOperations.SetBinding(pbv.Shape, Panel.ZIndexProperty,
                                             new Binding
                {
                    Path      = new PropertyPath(Panel.ZIndexProperty),
                    Source    = this,
                    Converter = new NextZIndexConverter()
                });

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

            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);
        }
示例#3
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 = (StepLinePointView)point.View;

            if (pbv == null)
            {
                pbv = new StepLinePointView
                {
                    IsNew          = true,
                    HorizontalLine = new Line(),
                    VerticalLine   = new Line()
                };

                Model.Chart.View.AddToDrawMargin(pbv.HorizontalLine);
                Model.Chart.View.AddToDrawMargin(pbv.VerticalLine);
                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);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.HorizontalLine);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.VerticalLine);
            }

            pbv.VerticalLine.StrokeThickness = StrokeThickness;
            pbv.VerticalLine.Stroke          = AlternativeStroke;
            pbv.VerticalLine.StrokeDashArray = StrokeDashArray;
            pbv.VerticalLine.Visibility      = Visibility;
            Canvas.SetZIndex(pbv.VerticalLine, Canvas.GetZIndex(this));

            pbv.HorizontalLine.StrokeThickness = StrokeThickness;
            pbv.HorizontalLine.Stroke          = Stroke;
            pbv.HorizontalLine.StrokeDashArray = StrokeDashArray;
            pbv.HorizontalLine.Visibility      = Visibility;
            Canvas.SetZIndex(pbv.HorizontalLine, Canvas.GetZIndex(this));

            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.StrokeThickness = StrokeThickness;
                pbv.Shape.Stroke          = Stroke;
                pbv.Shape.StrokeDashArray = StrokeDashArray;
                pbv.Shape.Visibility      = Visibility;
                pbv.Shape.Width           = PointGeometrySize;
                pbv.Shape.Height          = PointGeometrySize;
                pbv.Shape.Data            = PointGeometry.Parse();
                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 (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;
            }

            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 pbv = (StepLinePointView)point.View;

            if (pbv == null)
            {
                pbv = new StepLinePointView
                {
                    IsNew = true,
                    HorizontalLine = new Line(),
                    VerticalLine = new Line()
                };

                Model.Chart.View.AddToDrawMargin(pbv.HorizontalLine);
                Model.Chart.View.AddToDrawMargin(pbv.VerticalLine);
                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);
                point.SeriesView.Model.Chart.View
                    .EnsureElementBelongsToCurrentDrawMargin(pbv.HorizontalLine);
                point.SeriesView.Model.Chart.View
                    .EnsureElementBelongsToCurrentDrawMargin(pbv.VerticalLine);
            }

            pbv.VerticalLine.StrokeThickness = StrokeThickness;
            pbv.VerticalLine.Stroke = AlternativeStroke;
            pbv.VerticalLine.StrokeDashArray = StrokeDashArray;
            pbv.VerticalLine.Visibility = Visibility;
            Canvas.SetZIndex(pbv.VerticalLine, Canvas.GetZIndex(this));

            pbv.HorizontalLine.StrokeThickness = StrokeThickness;
            pbv.HorizontalLine.Stroke = Stroke;
            pbv.HorizontalLine.StrokeDashArray = StrokeDashArray;
            pbv.HorizontalLine.Visibility = Visibility;
            Canvas.SetZIndex(pbv.HorizontalLine, Canvas.GetZIndex(this));

            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.StrokeThickness = StrokeThickness;
                pbv.Shape.Stroke = Stroke;
                pbv.Shape.StrokeDashArray = StrokeDashArray;
                pbv.Shape.Visibility = Visibility;
                pbv.Shape.Width = PointGeometrySize;
                pbv.Shape.Height = PointGeometrySize;
                pbv.Shape.Data = PointGeometry.Parse();
                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 (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;

            return pbv;
        }