Example4_2.ChartStyle.SetChartArea C# (CSharp) Метод

SetChartArea() публичный Метод

public SetChartArea ( Graphics g ) : void
g System.Drawing.Graphics
Результат void
        public void SetChartArea(Graphics g)
        {
            SetPlotPanel(g);
            // Draw chart area:
            Pen aPen = new Pen(ChartBorderColor, 1f);
            SolidBrush aBrush = new SolidBrush(ChartBackColor);
            SizeF tickFontSize = g.MeasureString("A", TickFont);
            g.FillRectangle(aBrush, ChartArea);
            g.DrawRectangle(aPen, ChartArea);

            // Create the x-axis tick labels:
            aBrush = new SolidBrush(TickFontColor);
            float xm = XLimMin + XTickOffset;
            float xticklabel = 0f;
            if (BarType == BarTypeEnum.Vertical ||
                BarType == BarTypeEnum.VerticalOverlay ||
                BarType == BarTypeEnum.VerticalStack)
            {
                xm = XTickOffset + XLimMin + XTick / 2;
                xticklabel = XTick / 2;

            }

            for (float fX =  xm; fX <= XLimMax; fX += XTick)
            {
                PointF yAxisPoint = Point2D(new PointF(fX, YLimMin));
                StringFormat sFormat = new StringFormat();
                sFormat.Alignment = StringAlignment.Center;
                g.DrawString((fX + xticklabel).ToString(), TickFont, aBrush,
                    new PointF(form1.PlotPanel.Left + yAxisPoint.X,
                    form1.PlotPanel.Top + yAxisPoint.Y + 4f), sFormat);
            }

            // Create the y-axis tick labels:
            float ym = YLimMin + YTickOffset;
            float yticklabel = 0f;
            if (BarType == BarTypeEnum.Horizontal ||
                BarType == BarTypeEnum.HorizontalOverlay ||
                BarType == BarTypeEnum.HorizontalStack)
            {
                ym = YTickOffset + YLimMin + YTick / 2;
                yticklabel = YTick / 2;
            }
            for (float fY = ym; fY <= YLimMax; fY += YTick)
            {
                PointF xAxisPoint = Point2D(new PointF(XLimMin, fY));
                StringFormat sFormat = new StringFormat();
                sFormat.Alignment = StringAlignment.Far;
                g.DrawString((fY + yticklabel).ToString(), TickFont, aBrush,
                    new PointF(form1.PlotPanel.Left + xAxisPoint.X - 3f,
                    form1.PlotPanel.Top + xAxisPoint.Y
                    - tickFontSize.Height / 2), sFormat);
            }

            AddLabels(g);
        }

Usage Example

        public override void DrawRect(System.Drawing.RectangleF dirtyRect)
        {
            var g = new Graphics();

            g.Clear(backColor);

            cs.ChartArea = this.ClientRectangle;
            cs.SetChartArea(g);
        }
All Usage Examples Of Example4_2.ChartStyle::SetChartArea