コード例 #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);
        }