Beispiel #1
0
        public void Render(SKCanvas canvas, SKRect plotRect)
        {
            // update plot-level layout with the latest plot dimensions
            layout.Update(plotRect);

            if (!axes.x.isValid || !axes.y.isValid)
            {
                AutoAxis();
            }

            axes.SetDataRect(layout.dataRect);
            axes2.SetDataRect(layout.dataRect);

            // draw the graphics
            yTicks.Generate(axes.y.low, axes.y.high, layout.dataRect);
            y2Ticks.Generate(axes2.y.low, axes2.y.high, layout.dataRect);
            xTicks.Generate(axes.x.low, axes.x.high, layout.dataRect);
            if (yTicks.biggestTickLabelSize.Width > layout.yScaleWidth)
            {
                Debug.WriteLine("increasing Y scale width to prevent overlapping with label Y label");
                layout.yScaleWidth = yTicks.biggestTickLabelSize.Width;
                layout.Update(plotRect);
            }

            var fillPaint = new SKPaint();

            fillPaint.Color = SKColor.Parse("#FFFFFF");
            //fillPaint.Color = Tools.RandomColor(); // useful for assessing when plots are redrawn
            canvas.DrawRect(layout.dataRect, fillPaint);

            yTicks.Render(canvas, axes);
            y2Ticks.Render(canvas, axes2);
            xTicks.Render(canvas, axes);

            canvas.Save();
            canvas.ClipRect(axes.GetDataRect());

            foreach (var primaryPlottable in GetPlottableList(false))
            {
                primaryPlottable.Render(canvas, axes);
            }
            foreach (var secondaryPlottable in GetPlottableList(true))
            {
                secondaryPlottable.Render(canvas, axes2);
            }

            canvas.Restore();

            //RenderLayoutDebug(canvas);
            RenderLabels(canvas);
        }
Beispiel #2
0
        /// <summary>
        /// Adjust the ticks to fit the current layout
        /// </summary>
        private void UpdateTicks()
        {
            axes.SetDataRect(layout.dataRect);
            axes2.SetDataRect(layout.dataRect);

            yTicks.Generate(axes.y.low, axes.y.high, layout.dataRect);
            y2Ticks.Generate(axes2.y.low, axes2.y.high, layout.dataRect);
            xTicks.Generate(axes.x.low, axes.x.high, layout.dataRect);

            if (yTicks.biggestTickLabelSize.Width > layout.yScaleWidth)
            {
                layout.yScaleWidth = yTicks.biggestTickLabelSize.Width;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Return a new Axes after mouse panning and zooming
        /// </summary>
        private PlotSettings.Axes AxesAfterMouse(RectangleF?renderArea = null)
        {
            if (renderArea is null)
            {
                renderArea = mouse.lastRenderArea;
            }
            else
            {
                mouse.lastRenderArea = (RectangleF)renderArea;
            }

            var axesAfterMouse = new PlotSettings.Axes(axes);

            if (mouse.leftButtonIsDown)
            {
                axesAfterMouse.PanPixels(mouse.leftDelta);
            }
            if (mouse.rightButtonIsDown)
            {
                axesAfterMouse.ZoomPixels(mouse.rightDelta);
            }
            axesAfterMouse.SetDataRect((RectangleF)renderArea);
            return(axesAfterMouse);
        }