/// <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 = (RowPointView)point.View;

            if (pbv == null)
            {
                pbv = new RowPointView
                {
                    IsNew         = true,
                    Rectangle     = new Rectangle(),
                    Data          = new CoreRectangle(),
                    LabelPosition = BarLabelPosition.Merged
                };

                Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
            }
            else
            {
                pbv.IsNew = false;
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.Rectangle);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
            }

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

            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);
        }
Beispiel #2
0
        public override IChartPointView GetPointView(IChartPointView view, ChartPoint point, string label)
        {
            var pbv = (view as RowPointView);

            if (pbv == null)
            {
                pbv = new RowPointView
                {
                    IsNew       = true,
                    Rectangle   = new Rectangle(),
                    Data        = new CoreRectangle(),
                    LabelInside = true
                };

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

                Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
            }
            else
            {
                pbv.IsNew = false;
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.Rectangle);
                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;
            }

            return(pbv);
        }
Beispiel #3
0
        public override IChartPointView GetPointView(IChartPointView view, ChartPoint point, string label)
        {
            var pbv = (view as RowPointView);

            if (pbv == null)
            {
                pbv = new RowPointView
                {
                    IsNew     = true,
                    Rectangle = new Rectangle(),
                    Data      = new CoreRectangle()
                };

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

                Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
            }
            else
            {
                pbv.IsNew = false;
            }

            if ((Model.Chart.View.HasTooltip || Model.Chart.View.HasDataClickEventAttached) && 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 = Model.Chart.View as Chart;
                if (wpfChart == null)
                {
                    return(null);
                }
                wpfChart.AttachEventsTo(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;
            }

            return(pbv);
        }
Beispiel #4
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 = (RowPointView)point.View;

            if (pbv == null)
            {
                pbv = new RowPointView
                {
                    IsNew     = true,
                    Rectangle = new Rectangle(),
                    Data      = new CoreRectangle()
                };

                Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
            }
            else
            {
                pbv.IsNew = false;
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.Rectangle);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
            }

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

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


            pbv.LabelPosition = LabelsPosition;

            return(pbv);
        }
Beispiel #5
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 pbv = (RowPointView)point.View;

            if (pbv == null)
            {
                pbv = new RowPointView
                {
                    IsNew     = true,
                    Rectangle = new Rectangle(),
                    Data      = new CoreRectangle()
                };

                Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
            }
            else
            {
                pbv.IsNew = false;
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.Rectangle);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
                point.SeriesView.Model.Chart.View
                .EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
            }

            // add event handler to pbv.Rectangle
            if (UseRelativeMode)
            {
                var wpfChart = (Chart)Model.Chart.View;
                wpfChart.AttachRelativeModeEventTo(pbv.Rectangle, label);
            }

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

            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,
                    Point         = point
                }, pbv.DataLabel);

                //public void SetDataLabelForeground(Color color)
                //{
                //    var chartPoints = ActualValues.GetPoints(this);

                //    if (chartPoints == null)
                //        return;

                //    foreach (var point in chartPoints)
                //    {
                //        var pbv = (RowPointView)point.View;
                //        pbv.DataLabel.Foreground = new SolidColorBrush(color);
                //    }
                //}
            }

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

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

            pbv.LabelPosition = LabelsPosition;

            return(pbv);
        }