MTExample4_1.ChartStyle.PlotPanelStyle C# (CSharp) Method

PlotPanelStyle() public method

public PlotPanelStyle ( Graphics g ) : void
g System.Drawing.Graphics
return void
        public void PlotPanelStyle(Graphics g)
        {
            var aPen = new Pen (ChartBorderColor, 1f);
            var aBrush = new SolidBrush (ChartBackColor);

            // Create vertical gridlines:
            float fX, fY, xm, ym;

            aPen = new Pen(GridColor, 1f);
            aPen.DashStyle = GridPattern;
            xm = XLimMin + XTickOffset;
            if (BarType == BarTypeEnum.Vertical || BarType == BarTypeEnum.VerticalOverlay || BarType == BarTypeEnum.VerticalStack)
                xm = XTickOffset + XLimMin + XTick / 2;

            // Create vertical gridelines:
            if (IsYGrid == true) {
                for (fX = xm; fX < XLimMax; fX += XTick) {
                    g.DrawLine (aPen, Point2D (new CGPoint (fX, YLimMin)), Point2D (new CGPoint (fX, YLimMax)));
                }
            }
            // Create the x-axis tick marks:
            for (fX = xm; fX < XLimMax; fX += XTick) {
                Point yAxisPoint = Point2D (new CGPoint(fX, YLimMin));
                g.DrawLine (Pens.Black, yAxisPoint, new PointF (yAxisPoint.X, yAxisPoint.Y - 8f));
            }

            // Create horizontal gridlines:
            aPen = new Pen(GridColor, 1f);
            aPen.DashStyle = GridPattern;
            ym = YLimMin + YTickOffset;
            if (BarType == BarTypeEnum.Horizontal || BarType == BarTypeEnum.HorizontalOverlay || BarType == BarTypeEnum.HorizontalStack) {
                ym = YTickOffset + YLimMin + YTick / 2;
            }

            if (IsXGrid == true) {
                for (fY = ym; fY < YLimMax; fY += YTick) {
                    g.DrawLine(aPen, Point2D(new CGPoint(XLimMin, fY)),
                        Point2D(new CGPoint(XLimMax, fY)));
                }
            }

            // Create the y-axis tick marks:
            for (fY = ym; fY < YLimMax; fY += YTick) {
                Point xAxisPoint = Point2D (new CGPoint(XLimMin, fY));
                g.DrawLine (Pens.Black, xAxisPoint, new PointF (xAxisPoint.X + 5f, xAxisPoint.Y));
            }
            aPen.Dispose ();
            aBrush.Dispose ();
        }

Usage Example

Ejemplo n.º 1
0
        void PlotPanelPaint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            AddData(g);
            cs.PlotPanelStyle(g);
            dc.AddBars(g, cs, dc.DataSeriesList.Count, ds.PointList.Count);
        }