Beispiel #1
0
        private void DrawTicks(Layout layout, Axes axes, SKCanvas canvas)
        {
            // TODO: this tick drawing code is just a placeholder.

            float tickLength = 3;

            left.GenerateTicks(axes.y.low, axes.y.high, layout.scaleLeft.Height, 40);
            for (int i = 0; i < left.tickPositions.Length; i++)
            {
                float   yPos      = axes.GetPixel(0, left.tickPositions[i]).Y;
                SKPoint tickRight = new SKPoint(layout.scaleLeft.Right, yPos);
                SKPoint tickLeft  = new SKPoint(layout.scaleLeft.Right - tickLength, yPos);
                canvas.DrawLine(tickLeft, tickRight, left.paint);
                SKPaint paint = left.paint;
                paint.TextAlign = SKTextAlign.Right;
                canvas.DrawText(left.tickLabels[i], tickLeft.X, yPos, paint);
            }

            right.GenerateTicks(axes.y.low, axes.y.high, layout.scaleRight.Height, 40);
            for (int i = 0; i < right.tickPositions.Length; i++)
            {
                float   yPos      = axes.GetPixel(0, right.tickPositions[i]).Y;
                SKPoint tickRight = new SKPoint(layout.scaleRight.Left + tickLength, yPos);
                SKPoint tickLeft  = new SKPoint(layout.scaleRight.Left, yPos);
                canvas.DrawLine(tickLeft, tickRight, right.paint);
                SKPaint paint = left.paint;
                paint.TextAlign = SKTextAlign.Left;
                canvas.DrawText(right.tickLabels[i], tickRight.X, yPos, paint);
            }

            bottom.GenerateTicks(axes.x.low, axes.x.high, layout.scaleBottom.Width, 80);
            for (int i = 0; i < bottom.tickPositions.Length; i++)
            {
                float   xPos       = axes.GetPixel(bottom.tickPositions[i], 0).X;
                SKPoint tickTop    = new SKPoint(xPos, layout.scaleBottom.Top);
                SKPoint tickBottom = new SKPoint(xPos, layout.scaleBottom.Top + tickLength);
                canvas.DrawLine(tickTop, tickBottom, bottom.paint);
                SKPaint paint = left.paint;
                paint.TextAlign = SKTextAlign.Center;
                canvas.DrawText(bottom.tickLabels[i], xPos, tickBottom.Y + bottom.paint.TextSize, paint);
            }

            top.GenerateTicks(axes.x.low, axes.x.high, layout.scaleTop.Width, 80);
            for (int i = 0; i < top.tickPositions.Length; i++)
            {
                float   xPos       = axes.GetPixel(top.tickPositions[i], 0).X;
                SKPoint tickTop    = new SKPoint(xPos, layout.scaleTop.Bottom - tickLength);
                SKPoint tickBottom = new SKPoint(xPos, layout.scaleTop.Bottom);
                canvas.DrawLine(tickTop, tickBottom, top.paint);
                SKPaint paint = left.paint;
                paint.TextAlign = SKTextAlign.Center;
                canvas.DrawText(top.tickLabels[i], xPos, tickTop.Y - 2, paint);
            }
        }
Beispiel #2
0
        private void RenderLeft(SKCanvas canvas, Axes axes)
        {
            SKPaint paintTick = new SKPaint()
            {
                IsAntialias = true,
                TextSize    = 12,
                TextAlign   = SKTextAlign.Right,
                Color       = SKColor.Parse("#FF000000")
            };

            SKPaint paintGrid = new SKPaint()
            {
                IsAntialias = true,
                Color       = SKColor.Parse("#33000000")
            };

            SKRect dataRect = axes.GetDataRect();

            foreach (Tick tick in ticks)
            {
                if ((tick.value >= axes.y.low) && (tick.value <= axes.y.high))
                {
                    float   yPixel    = axes.GetPixel(0, tick.value).Y;
                    SKPoint dataLeft  = new SKPoint(dataRect.Left, yPixel);
                    SKPoint dataRight = new SKPoint(dataRect.Right, yPixel);
                    SKPoint tickLeft  = new SKPoint(dataRect.Left - length, yPixel);
                    canvas.DrawLine(tickLeft, dataLeft, paintTick);
                    canvas.DrawText(tick.label, tickLeft.X - 3, yPixel + paintTick.TextSize * 0.35f, paintTick);
                    canvas.DrawLine(dataLeft, dataRight, paintGrid);
                }
            }
        }
Beispiel #3
0
        private void RenderBottom(SKCanvas canvas, Axes axes)
        {
            SKPaint paintTick = new SKPaint()
            {
                IsAntialias = true,
                TextSize    = 12,
                TextAlign   = SKTextAlign.Center,
                Color       = SKColor.Parse("#FF000000")
            };

            SKPaint paintGrid = new SKPaint()
            {
                IsAntialias = true,
                Color       = SKColor.Parse("#33000000")
            };

            SKRect dataRect = axes.GetDataRect();

            foreach (Tick tick in ticks)
            {
                if ((tick.value >= axes.x.low) && (tick.value <= axes.x.high))
                {
                    float   xPixel  = axes.GetPixel(tick.value, 0).X;
                    SKPoint dataTop = new SKPoint(xPixel, dataRect.Top);
                    SKPoint dataBot = new SKPoint(xPixel, dataRect.Bottom);
                    SKPoint tickBot = new SKPoint(xPixel, dataRect.Bottom + length);
                    canvas.DrawLine(dataBot, tickBot, paintTick);
                    canvas.DrawText(tick.label, xPixel, tickBot.Y + paintTick.TextSize, paintTick);
                    canvas.DrawLine(dataBot, dataTop, paintGrid);
                }
            }
        }
Beispiel #4
0
        private void RenderLeft(SKCanvas canvas, Axes axes)
        {
            var yTickPaint = new SKPaint()
            {
                IsAntialias = true,
                TextSize    = 12,
                TextAlign   = SKTextAlign.Right,
                Color       = yTickColor
            };

            var gridPaint = new SKPaint()
            {
                IsAntialias = true,
                Color       = gridColor
            };

            SKRect dataRect = axes.GetDataRect();

            foreach (Tick tick in ticks)
            {
                if ((tick.value >= axes.y.low) && (tick.value <= axes.y.high))
                {
                    float   yPixel    = axes.GetPixel(0, tick.value).Y;
                    SKPoint dataLeft  = new SKPoint(dataRect.Left, yPixel);
                    SKPoint dataRight = new SKPoint(dataRect.Right, yPixel);
                    SKPoint tickLeft  = new SKPoint(dataRect.Left - length, yPixel);
                    canvas.DrawLine(tickLeft, dataLeft, yTickPaint);
                    canvas.DrawText(tick.label, tickLeft.X - 3, yPixel + yTickPaint.TextSize * 0.35f, yTickPaint);
                    canvas.DrawLine(dataLeft, dataRight, gridPaint);
                }
            }
        }
Beispiel #5
0
        private void RenderBottom(SKCanvas canvas, Axes axes)
        {
            var xTickPaint = new SKPaint()
            {
                IsAntialias = true,
                TextSize    = 12,
                TextAlign   = SKTextAlign.Center,
                Color       = xTickColor
            };

            var gridPaint = new SKPaint()
            {
                IsAntialias = true,
                Color       = gridColor
            };

            SKRect dataRect = axes.GetDataRect();

            foreach (Tick tick in ticks)
            {
                if ((tick.value >= axes.x.low) && (tick.value <= axes.x.high))
                {
                    float   xPixel  = axes.GetPixel(tick.value, 0).X;
                    SKPoint dataTop = new SKPoint(xPixel, dataRect.Top);
                    SKPoint dataBot = new SKPoint(xPixel, dataRect.Bottom);
                    SKPoint tickBot = new SKPoint(xPixel, dataRect.Bottom + length);
                    canvas.DrawLine(dataBot, tickBot, xTickPaint);
                    canvas.DrawText(tick.label, xPixel, tickBot.Y + xTickPaint.TextSize, xTickPaint);
                    canvas.DrawLine(dataBot, dataTop, gridPaint);
                }
            }
        }
Beispiel #6
0
        private void RenderLeft(Graphics gfx, Axes axes)
        {
            RectangleF   dataRect = axes.GetDataRect();
            StringFormat sf       = Tools.StringFormat(Tools.AlignHoriz.right, Tools.AlignVert.center);

            foreach (Tick tick in ticks)
            {
                if ((tick.value >= axes.y.low) && (tick.value <= axes.y.high))
                {
                    float yPixel = axes.GetPixel(0, tick.value).Y;
                    gfx.DrawLine(Pens.LightGray, dataRect.Left, yPixel, dataRect.Right, yPixel);
                    gfx.DrawLine(Pens.Black, dataRect.Left, yPixel, dataRect.Left - length, yPixel);
                    gfx.DrawString(tick.label, font, brush, new PointF(dataRect.Left - length, yPixel), sf);
                }
            }
        }
Beispiel #7
0
        private void RenderBottom(Graphics gfx, Axes axes)
        {
            RectangleF   dataRect = axes.GetDataRect();
            StringFormat sf       = Tools.StringFormat(Tools.AlignHoriz.center, Tools.AlignVert.top);

            foreach (Tick tick in ticks)
            {
                if ((tick.value >= axes.x.low) && (tick.value <= axes.x.high))
                {
                    float xPixel = axes.GetPixel(tick.value, 0).X;
                    gfx.DrawLine(Pens.LightGray, xPixel, dataRect.Bottom, xPixel, dataRect.Top);
                    gfx.DrawLine(Pens.Black, xPixel, dataRect.Bottom, xPixel, dataRect.Bottom + length);
                    gfx.DrawString(tick.label, font, brush, new PointF(xPixel, dataRect.Bottom + length), sf);
                }
            }
        }