Ejemplo n.º 1
0
        private void RenderLabels(SKCanvas canvas)
        {
            int pathExtend = 500;

            SKPath  titlePath  = new SKPath();
            SKPaint titlePaint = title.MakePaint();

            titlePath.MoveTo(layout.titleRect.Left - pathExtend, layout.titleRect.Top + titlePaint.TextSize);
            titlePath.LineTo(layout.titleRect.Right + pathExtend, layout.titleRect.Top + titlePaint.TextSize);
            canvas.DrawTextOnPath(title.text, titlePath, 0, 0, titlePaint);

            SKPath  yLabelPath  = new SKPath();
            SKPaint yLabelPaint = yLabel.MakePaint();

            yLabelPath.MoveTo(layout.yLabelRect.Left + yLabelPaint.TextSize, layout.yLabelRect.Bottom + pathExtend);
            yLabelPath.LineTo(layout.yLabelRect.Left + yLabelPaint.TextSize, layout.yLabelRect.Top - pathExtend);
            canvas.DrawTextOnPath(yLabel.text, yLabelPath, 0, 0, yLabelPaint);

            SKPath  y2LabelPath  = new SKPath();
            SKPaint y2LabelPaint = y2Label.MakePaint();

            y2LabelPath.MoveTo(layout.y2LabelRect.Right - y2LabelPaint.TextSize, layout.y2LabelRect.Top - pathExtend);
            y2LabelPath.LineTo(layout.y2LabelRect.Right - y2LabelPaint.TextSize, layout.y2LabelRect.Bottom + pathExtend);
            canvas.DrawTextOnPath(y2Label.text, y2LabelPath, 0, 0, y2LabelPaint);

            SKPath  xLabelPath  = new SKPath();
            SKPaint xLabelPaint = xLabel.MakePaint();

            xLabelPath.MoveTo(layout.xLabelRect.Left - pathExtend, layout.xLabelRect.Top + xLabelPaint.TextSize);
            xLabelPath.LineTo(layout.xLabelRect.Right + pathExtend, layout.xLabelRect.Top + xLabelPaint.TextSize);
            canvas.DrawTextOnPath(xLabel.text, xLabelPath, 0, 0, xLabelPaint);


            // Outline the data area

            SKPaint layoutFramePaint = new SKPaint()
            {
                Color       = SKColor.Parse("#000000"),
                Style       = SKPaintStyle.Stroke,
                IsAntialias = false
            };

            canvas.DrawRect(layout.dataRect, layoutFramePaint);
        }
Ejemplo n.º 2
0
        private void DrawLabels(SKCanvas canvas)
        {
            int pathExtend = 500;

            if (title.text != null)
            {
                SKPath  titlePath  = new SKPath();
                SKPaint titlePaint = title.MakePaint();
                float   yPixel     = layout.titleRect.CenterY() + layout.titleRect.Height / 5;
                titlePath.MoveTo(layout.titleRect.Left - pathExtend, yPixel);
                titlePath.LineTo(layout.titleRect.Right + pathExtend, yPixel);
                canvas.DrawTextOnPath(title.text, titlePath, 0, 0, titlePaint);
            }

            if (yLabel.text != null)
            {
                SKPath  yLabelPath  = new SKPath();
                SKPaint yLabelPaint = yLabel.MakePaint();
                float   xPixel      = layout.yLabelRect.Left + yLabelPaint.TextSize - yLabelPaint.TextSize / 5;
                yLabelPath.MoveTo(xPixel, layout.yLabelRect.Bottom + pathExtend);
                yLabelPath.LineTo(xPixel, layout.yLabelRect.Top - pathExtend);
                canvas.DrawTextOnPath(yLabel.text, yLabelPath, 0, 0, yLabelPaint);
            }

            if (y2Label.text != null)
            {
                SKPath  y2LabelPath  = new SKPath();
                SKPaint y2LabelPaint = y2Label.MakePaint();
                float   xPixel       = layout.y2LabelRect.Right - y2LabelPaint.TextSize + y2LabelPaint.TextSize / 5;
                y2LabelPath.MoveTo(xPixel, layout.y2LabelRect.Top - pathExtend);
                y2LabelPath.LineTo(xPixel, layout.y2LabelRect.Bottom + pathExtend);
                canvas.DrawTextOnPath(y2Label.text, y2LabelPath, 0, 0, y2LabelPaint);
            }

            if (xLabel.text != null)
            {
                SKPath  xLabelPath  = new SKPath();
                SKPaint xLabelPaint = xLabel.MakePaint();
                float   yPixel      = layout.xLabelRect.Bottom;
                xLabelPath.MoveTo(layout.xLabelRect.Left - pathExtend, yPixel);
                xLabelPath.LineTo(layout.xLabelRect.Right + pathExtend, yPixel);
                canvas.DrawTextOnPath(xLabel.text, xLabelPath, 0, 0, xLabelPaint);
            }
        }