Пример #1
0
        /// <summary>
        /// draws the y-axis labels to the screen
        /// </summary>
        public virtual void RenderAxisLabels(SKCanvas c)
        {
            if (!YAxis.IsEnabled || !YAxis.IsDrawLabelsEnabled)
            {
                return;
            }

            SKPoint[] positions = GetTransformedPositions();

            AxisLabelPaint.Typeface = YAxis.Typeface;
            AxisLabelPaint.TextSize = YAxis.TextSize;
            AxisLabelPaint.Color    = YAxis.TextColor;

            float xoffset = YAxis.XOffset;
            float yoffset = AxisLabelPaint.MeasureHeight("A") / 2.5f + YAxis.YOffset;

            YAxisDependency dependency = YAxis.AxisDependency;

            YAxis.YAxisLabelPosition labelPosition = YAxis.Position;

            float xPos;

            if (dependency == YAxisDependency.Left)
            {
                if (labelPosition == YAxis.YAxisLabelPosition.OutSideChart)
                {
                    AxisLabelPaint.TextAlign = SKTextAlign.Right;
                    xPos = ViewPortHandler.OffsetLeft - xoffset;
                }
                else
                {
                    AxisLabelPaint.TextAlign = SKTextAlign.Left;
                    xPos = ViewPortHandler.OffsetLeft + xoffset;
                }
            }
            else
            {
                if (labelPosition == YAxis.YAxisLabelPosition.OutSideChart)
                {
                    AxisLabelPaint.TextAlign = SKTextAlign.Left;
                    xPos = ViewPortHandler.ContentRight + xoffset;
                }
                else
                {
                    AxisLabelPaint.TextAlign = SKTextAlign.Right;
                    xPos = ViewPortHandler.ContentRight - xoffset;
                }
            }

            DrawYLabels(c, xPos, positions, yoffset);
        }
Пример #2
0
        public override void RenderAxisLabels(SKCanvas c)
        {
            if (!YAxis.IsEnabled || !YAxis.IsDrawLabelsEnabled)
            {
                return;
            }

            SKPoint[] positions = GetTransformedPositions();

            AxisLabelPaint.Typeface  = YAxis.Typeface;
            AxisLabelPaint.TextSize  = YAxis.TextSize;
            AxisLabelPaint.Color     = YAxis.TextColor;
            AxisLabelPaint.TextAlign = SKTextAlign.Center;

            float baseYOffset = 2.5f.DpToPixel();
            float textHeight  = AxisLabelPaint.MeasureHeight("Q");

            YAxisDependency dependency = YAxis.AxisDependency;

            YAxis.YAxisLabelPosition labelPosition = YAxis.Position;

            float yPos;

            if (dependency == YAxisDependency.Left)
            {
                if (labelPosition == YAxis.YAxisLabelPosition.OutSideChart)
                {
                    yPos = ViewPortHandler.ContentTop - baseYOffset;
                }
                else
                {
                    yPos = ViewPortHandler.ContentTop - baseYOffset;
                }
            }
            else
            {
                if (labelPosition == YAxis.YAxisLabelPosition.OutSideChart)
                {
                    yPos = ViewPortHandler.ContentBottom + textHeight + baseYOffset;
                }
                else
                {
                    yPos = ViewPortHandler.ContentBottom + textHeight + baseYOffset;
                }
            }

            DrawYLabels(c, yPos, positions, YAxis.YOffset);
        }
Пример #3
0
        protected virtual void ComputeSize()
        {
            var longest = XAxis.GetLongestLabel();

            AxisLabelPaint.Typeface = XAxis.Typeface;
            AxisLabelPaint.TextSize = XAxis.TextSize;

            var labelSize = AxisLabelPaint.Measure(longest);

            float labelWidth  = labelSize.Width;
            float labelHeight = AxisLabelPaint.MeasureHeight("Q");

            var labelRotatedSize = ChartUtil.GetSizeOfRotatedRectangleByDegrees(
                labelWidth,
                labelHeight,
                XAxis.LabelRotationAngle);


            XAxis.LabelWidth         = (int)Math.Round(labelWidth);
            XAxis.LabelHeight        = (int)Math.Round(labelHeight);
            XAxis.LabelRotatedWidth  = (int)MathF.Round(labelRotatedSize.Width);
            XAxis.LabelRotatedHeight = (int)MathF.Round(labelRotatedSize.Height);
        }