public void AddAreas(Graphics g, ChartStyle cs, int nSeries, int nPoints)
        {
            float[] ySum = new float[nPoints];
            PointF[] pts = new PointF[2 * nPoints];
            PointF[] pt0 = new PointF[nPoints];
            PointF[] pt1 = new PointF[nPoints];
            for (int i = 0; i < nPoints; i++) {
                ySum [i] = AreaAxis;
            }

            int n = 0;
            foreach (DataSeries ds in DataSeriesList) {
                Pen aPen = new Pen (ds.LineStyle.LineColor, ds.LineStyle.Thickness);
                aPen.DashStyle = ds.LineStyle.Pattern;
                Color fillColor = Color.FromArgb (CMap [n, 0], CMap [n, 1],
                    CMap [n, 2], CMap [n, 3]);
                SolidBrush aBrush = new SolidBrush (fillColor);

                // Draw lines and areas:
                if (ds.LineStyle.PlotMethod == LineStyle.PlotLinesMethodEnum.Lines) {
                    for (int i = 0; i < nPoints; i++) {
                        pt0 [i] = new PointF (((PointF)ds.PointList [i]).X, ySum [i]);
                        ySum [i] = ySum [i] + ((PointF)ds.PointList [i]).Y;
                        pt1 [i] = new PointF (((PointF)ds.PointList [i]).X, ySum [i]);
                        pts [i] = cs.Point2D (pt0 [i]);
                        pts [2 * nPoints - 1 - i] = cs.Point2D (pt1 [i]);
                    }
                    g.FillPolygon (aBrush, pts);
                    g.DrawPolygon (Pens.Black, pts);
                }
                n++;
            }
        }
示例#2
0
        public void AddAreas(Graphics g, ChartStyle cs, int nSeries, int nPoints)
        {
            float[]  ySum = new float[nPoints];
            PointF[] pts  = new PointF[2 * nPoints];
            PointF[] pt0  = new PointF[nPoints];
            PointF[] pt1  = new PointF[nPoints];
            for (int i = 0; i < nPoints; i++)
            {
                ySum [i] = AreaAxis;
            }

            int n = 0;

            foreach (DataSeries ds in DataSeriesList)
            {
                Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
                aPen.DashStyle = ds.LineStyle.Pattern;
                Color fillColor = Color.FromArgb(CMap [n, 0], CMap [n, 1],
                                                 CMap [n, 2], CMap [n, 3]);
                SolidBrush aBrush = new SolidBrush(fillColor);

                // Draw lines and areas:
                if (ds.LineStyle.PlotMethod == LineStyle.PlotLinesMethodEnum.Lines)
                {
                    for (int i = 0; i < nPoints; i++)
                    {
                        pt0 [i]  = new PointF(((PointF)ds.PointList [i]).X, ySum [i]);
                        ySum [i] = ySum [i] + ((PointF)ds.PointList [i]).Y;
                        pt1 [i]  = new PointF(((PointF)ds.PointList [i]).X, ySum [i]);
                        pts [i]  = cs.Point2D(pt0 [i]);
                        pts [2 * nPoints - 1 - i] = cs.Point2D(pt1 [i]);
                    }
                    g.FillPolygon(aBrush, pts);
                    g.DrawPolygon(Pens.Black, pts);
                }
                n++;
            }
        }
        // Shared initialization code
        void Initialize()
        {
            this.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;
            BackColor = Color.Wheat;
            PlotPanel = new PlotPanel(Frame);

            this.AddSubview(PlotPanel);

            // Subscribing to a paint eventhandler to drawingPanel:
            PlotPanel.Paint +=
                new PaintEventHandler(PlotPanelPaint);

            // Set Form1 size:
            //			this.Width = 350;
            //			this.Height = 300;
            // Subscribing to a paint eventhandler to drawingPanel:
            dc = new DataCollection();
            cs = new ChartStyle(this);
            cs.XLimMin = 0f;
            cs.XLimMax = 10f;
            cs.YLimMin = 0f;
            cs.YLimMax = 10f;
            cs.XTick = 2.0f;
            cs.YTick = 2.0f;
            cs.XLabel = "This is X axis";
            cs.YLabel = "This is Y axis";
            cs.Title = "Area Plot";
            cs.IsXGrid = true;
            cs.IsYGrid = true;
        }