Ejemplo n.º 1
0
        protected virtual void DrawGrid(CGContext context, IViewPort viewPort, IYAxis yAxis, nfloat axisLineStart, nfloat axisLineEnd, GridStyle gridStyle)
        {
            var Step = gridStyle.Step;

            var visibleSourceRangeStart = yAxis.Min - (yAxis.Min % Step) - Step;

            var visibleSourceRangeEnd = yAxis.Max - (yAxis.Max % Step) + Step;

            var leftAxisX = viewPort.ViewPortRect.Left + gridStyle.Offset.X;

            var rightAxisX = viewPort.ViewPortRect.Right - gridStyle.Offset.X;

            for (double i = visibleSourceRangeStart; i <= visibleSourceRangeEnd; i += Step)
            {
                var y = yAxis.GetContentValue(i);

                var viewPortPositionY = viewPort.DisplayPositionY((nfloat)y) + gridStyle.Offset.Y;

                if (viewPortPositionY >= axisLineStart && viewPortPositionY <= axisLineEnd)
                {
                    DrawHelper.DrawLines(context, new List <CGPoint> {
                        new CGPoint(leftAxisX, viewPortPositionY), new CGPoint(rightAxisX, viewPortPositionY)
                    }, gridStyle);
                }
            }
        }
Ejemplo n.º 2
0
        private void DrawLabels(CGContext context, IViewPort viewPort, IYAxis yAxis, nfloat positionX, nfloat axisLineStart, nfloat axisLineEnd, TextStyle textStyle, List <Tuple <double, string> > labels)
        {
            foreach (var label in labels)
            {
                var labelY = yAxis.GetContentValue(label.Item1);

                var viewPortPositionY = viewPort.DisplayPositionY((nfloat)labelY);

                if (viewPortPositionY >= axisLineStart && viewPortPositionY <= axisLineEnd)
                {
                    DrawLabel(context, label.Item2, new CGPoint(positionX, viewPortPositionY), textStyle);
                }
            }
        }