Exemple #1
0
        private static double GetLabelSlotY(ChartAnnotationLabelUpdateContext context, RadSize labelSize, double strokeThickness, double strokeCompensation)
        {
            ChartAnnotationLabelLocation location = context.Definition.Location;
            RadRect           annotationSlot      = context.LayoutSlot;
            VerticalAlignment verticalAlignment   = context.Definition.VerticalAlignment;
            double            verticalOffset      = context.Definition.VerticalOffset;
            double            y = context.Location.Y;

            switch (location)
            {
            case ChartAnnotationLabelLocation.Top:
            {
                y = annotationSlot.Y - strokeCompensation - labelSize.Height;
                break;
            }

            case ChartAnnotationLabelLocation.Bottom:
            {
                y = annotationSlot.Bottom + strokeCompensation;
                break;
            }

            case ChartAnnotationLabelLocation.Left:
            case ChartAnnotationLabelLocation.Right:
            {
                switch (verticalAlignment)
                {
                case VerticalAlignment.Top:
                    y = annotationSlot.Y;
                    break;

                case VerticalAlignment.Center:
                    y = annotationSlot.Y + ((annotationSlot.Height - labelSize.Height) / 2);
                    break;

                case VerticalAlignment.Bottom:
                    y = annotationSlot.Bottom - labelSize.Height;
                    break;
                }
                break;
            }

            case ChartAnnotationLabelLocation.Inside:
            {
                switch (verticalAlignment)
                {
                case VerticalAlignment.Top:
                    y = annotationSlot.Y + strokeThickness;
                    break;

                case VerticalAlignment.Center:
                    y = annotationSlot.Y + ((annotationSlot.Height - labelSize.Height) / 2);
                    break;

                case VerticalAlignment.Bottom:
                    y = annotationSlot.Bottom - strokeThickness - labelSize.Height;
                    break;
                }
                break;
            }
            }

            y += verticalOffset;

            return(y);
        }
Exemple #2
0
        private static double GetLabelSlotX(ChartAnnotationLabelUpdateContext context, RadSize labelSize, double strokeThickness, double strokeCompensation)
        {
            ChartAnnotationLabelLocation location   = context.Definition.Location;
            RadRect             annotationSlot      = context.LayoutSlot;
            HorizontalAlignment horizontalAlignment = context.Definition.HorizontalAlignment;
            double horizontalOffset = context.Definition.HorizontalOffset;
            double x = context.Location.X;

            switch (location)
            {
            case ChartAnnotationLabelLocation.Left:
            {
                x = annotationSlot.X - strokeCompensation - labelSize.Width;
                break;
            }

            case ChartAnnotationLabelLocation.Right:
            {
                x = annotationSlot.Right + strokeCompensation;
                break;
            }

            case ChartAnnotationLabelLocation.Top:
            case ChartAnnotationLabelLocation.Bottom:
            {
                switch (horizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    x = annotationSlot.X;
                    break;

                case HorizontalAlignment.Center:
                    x = annotationSlot.X + ((annotationSlot.Width - labelSize.Width) / 2);
                    break;

                case HorizontalAlignment.Right:
                    x = annotationSlot.Right - labelSize.Width;
                    break;
                }
                break;
            }

            case ChartAnnotationLabelLocation.Inside:
            {
                switch (horizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    x = annotationSlot.X + strokeThickness;
                    break;

                case HorizontalAlignment.Center:
                    x = annotationSlot.X + ((annotationSlot.Width - labelSize.Width) / 2);
                    break;

                case HorizontalAlignment.Right:
                    x = annotationSlot.Right - strokeThickness - labelSize.Width;
                    break;
                }
                break;
            }
            }

            x += horizontalOffset;

            return(x);
        }