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++;
            }
        }
Ejemplo n.º 2
0
        public ChartCanvas(CGRect rect)
            : base(rect)
        {
            ContentMode = UIViewContentMode.Redraw;
            AutoresizingMask = UIViewAutoresizing.All;
            BackColor = Color.Wheat;

            PlotPanel = new PlotPanel (rect);

            AddSubview (PlotPanel);

            // Subscribing to a paint eventhandler to drawingPanel:
            PlotPanel.Paint += PlotPanelPaint;

            dc = new DataCollection ();
            cs = new ChartStyle (this);
            cs.XLimMin = 0f;
            cs.XLimMax = 10f;
            cs.YLimMin = 0f;
            cs.YLimMax = 10f;
            cs.XTick = 2f;
            cs.YTick = 2f;
            cs.XLabel = "This is X axis";
            cs.YLabel = "This is Y axis";
            cs.Title = "Area Plot";
            cs.IsXGrid = true;
            cs.IsYGrid = true;
        }
Ejemplo n.º 3
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++;
            }
        }