Exemplo n.º 1
0
        private void AddChart()
        {
            cs   = new ChartStyleGridlines();
            dc   = new DataCollectionArea();
            area = new DataSeriesArea();

            cs.ChartCanvas     = chartCanvas;
            cs.TextCanvas      = textCanvas;
            cs.Title           = "Area Chart";
            cs.Xmin            = 0;
            cs.Xmax            = 10;
            cs.Ymin            = 0;
            cs.Ymax            = 10;
            cs.XTick           = 2;
            cs.YTick           = 2;
            cs.GridlinePattern = ChartStyleGridlines.GridlinePatternEnum.Dot;
            cs.GridlineColor   = Brushes.Black;
            cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel);
            dc.AreaList.Clear();

            // Add sine data:
            area             = new DataSeriesArea();
            area.BorderColor = Brushes.Black;
            area.FillColor   = Brushes.LightPink;
            for (int i = 0; i < 41; i++)
            {
                area.AreaSeries.Points.Add(new Point(0.25 * i, 2.0 + Math.Sin(0.25 * i)));
            }
            dc.AreaList.Add(area);

            // Add cosine data:
            area             = new DataSeriesArea();
            area.BorderColor = Brushes.Black;
            area.FillColor   = Brushes.LightBlue;
            for (int i = 0; i < 41; i++)
            {
                area.AreaSeries.Points.Add(new Point(0.25 * i, 2.0 + Math.Cos(0.25 * i)));
            }
            dc.AreaList.Add(area);

            // Add another sine data:
            area             = new DataSeriesArea();
            area.BorderColor = Brushes.Black;
            area.FillColor   = Brushes.LightGreen;
            for (int i = 0; i < 41; i++)
            {
                area.AreaSeries.Points.Add(new Point(0.25 * i, 3.0 + Math.Sin(0.25 * i)));
            }
            dc.AreaList.Add(area);
            dc.AddAreas(cs);
        }
        private void AddVerticalBarChart()
        {
            cs = new ChartStyleGridlines();
            dc = new DataCollectionBar();
            ds = new DataSeriesBar();

            dc.BarType         = DataCollectionBar.BarTypeEnum.Vertical;
            cs.ChartCanvas     = chartCanvas;
            cs.TextCanvas      = textCanvas;
            cs.Title           = "Bar Chart";
            cs.Xmin            = 0;
            cs.Xmax            = 5;
            cs.Ymin            = 0;
            cs.Ymax            = 10;
            cs.XTick           = 1;
            cs.YTick           = 2;
            cs.GridlinePattern = ChartStyleGridlines.GridlinePatternEnum.Dot;
            cs.GridlineColor   = Brushes.Black;
            cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel);

            // Draw the bar chart:
            dc.DataList.Clear();
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Green;
            ds.BarWidth    = 0.6;

            /*for (int i = 0; i < 5; i++)
             * {
             *  double x = i + 1.0;
             *  double y = 2.0 * x;
             *  ds.LineSeries.Points.Add(new Point(x, y));
             * }*/

            double[] x = new double[] { 1, 2, 3, 4, 5 };
            double[] y = new double[] { 2, 0, 3, 8, 10 };
            for (int i = 0; i < x.Length; i++)
            {
                ds.LineSeries.Points.Add(new Point(x[i], y[i]));
            }

            dc.DataList.Add(ds);
            dc.AddBars(cs);
        }
        private void AddChart()
        {
            cs = new ChartStyleGridlines();
            dc = new DataCollectionStem();
            ds = new DataSeries();

            cs.ChartCanvas     = chartCanvas;
            cs.TextCanvas      = textCanvas;
            cs.Title           = "Stem Chart";
            cs.Xmin            = 0;
            cs.Xmax            = 8;
            cs.Ymin            = -1.5;
            cs.Ymax            = 1.5;
            cs.XTick           = 1;
            cs.YTick           = 0.5;
            cs.GridlinePattern = ChartStyleGridlines.GridlinePatternEnum.Dot;
            cs.GridlineColor   = Brushes.Black;
            cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel);

            // Draw the stair step chart:
            dc.DataList.Clear();
            ds = new DataSeries();

            for (int i = 0; i < 50; i++)
            {
                ds.LineSeries.Points.Add(new Point(0.4 * i, Math.Sin(0.4 * i)));
            }

            ds.LineColor           = Brushes.Red;
            ds.Symbols.SymbolType  = Symbols.SymbolTypeEnum.Diamond;
            ds.Symbols.FillColor   = Brushes.Yellow;
            ds.Symbols.BorderColor = Brushes.DarkGreen;


            dc.DataList.Add(ds);
            dc.AddStems(cs);
        }
Exemplo n.º 4
0
        private void AddChart()
        {
            cs = new ChartStyleGridlines();
            dc = new DataCollectionErrorbar();
            ds = new DataSeriesErrorbar();

            cs.ChartCanvas     = chartCanvas;
            cs.TextCanvas      = textCanvas;
            cs.Title           = "Error Bar Chart";
            cs.Xmin            = 0;
            cs.Xmax            = 12;
            cs.Ymin            = -1;
            cs.Ymax            = 6;
            cs.XTick           = 2;
            cs.YTick           = 1;
            cs.GridlinePattern = ChartStyleGridlines.GridlinePatternEnum.Dot;
            cs.GridlineColor   = Brushes.Black;
            cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel);

            dc.DataList.Clear();
            dc.ErrorList.Clear();
            ds                     = new DataSeriesErrorbar();
            ds.LineColor           = Brushes.Blue;
            ds.Symbols.SymbolType  = Symbols.SymbolTypeEnum.Circle;
            ds.Symbols.BorderColor = Brushes.DarkGreen;
            ds.ErrorLineColor      = Brushes.Red;

            for (int i = 2; i < 22; i++)
            {
                ds.LineSeries.Points.Add(new Point(0.5 * i, 10.0 * Math.Exp(-0.5 * i)));
                ds.ErrorLineSeries.Points.Add(new Point(0.5 * i, 3.0 / (0.5 * i)));
            }
            dc.DataList.Add(ds);
            dc.AddErrorbars(cs);
            dc.AddLines(cs);
        }
        private void AddHorizontalBarChart()
        {
            cs = new ChartStyleGridlines();
            dc = new DataCollectionBar();
            ds = new DataSeriesBar();

            dc.BarType         = DataCollectionBar.BarTypeEnum.Horizontal;
            cs.ChartCanvas     = chartCanvas;
            cs.TextCanvas      = textCanvas;
            cs.Title           = "Bar Chart";
            cs.Xmin            = 0;
            cs.Xmax            = 10;
            cs.Ymin            = 0;
            cs.Ymax            = 5;
            cs.XTick           = 2;
            cs.YTick           = 1;
            cs.GridlinePattern = ChartStyleGridlines.GridlinePatternEnum.Dot;
            cs.GridlineColor   = Brushes.Black;
            cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel);

            // Draw the bar chart:
            dc.DataList.Clear();
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Green;
            ds.BarWidth    = 0.6;

            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = 2.0 * x;
                ds.LineSeries.Points.Add(new Point(y, x));
            }
            dc.DataList.Add(ds);
            dc.AddBars(cs);
        }
        private void AddVerticalGroupBarChart()
        {
            cs = new ChartStyleGridlines();
            dc = new DataCollectionBar();
            ds = new DataSeriesBar();

            dc.BarType         = DataCollectionBar.BarTypeEnum.VerticalStack;
            cs.ChartCanvas     = chartCanvas;
            cs.TextCanvas      = textCanvas;
            cs.Title           = dc.BarType.ToString();
            cs.Xmin            = 0;
            cs.Xmax            = 5;
            cs.Ymin            = 0;
            cs.Ymax            = 25;
            cs.XTick           = 1;
            cs.YTick           = 5;
            cs.GridlinePattern = ChartStyleGridlines.GridlinePatternEnum.Dot;
            cs.GridlineColor   = Brushes.Black;
            cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel);

            // Add the first bar series:
            dc.DataList.Clear();
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Green;
            ds.BarWidth    = 0.8;

            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = 2.0 * x;
                ds.LineSeries.Points.Add(new Point(x, y));
            }
            dc.DataList.Add(ds);

            // Add the second bar series:
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Yellow;
            ds.BarWidth    = 0.8;

            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = 1.5 * x;
                ds.LineSeries.Points.Add(new Point(x, y));
            }
            dc.DataList.Add(ds);

            // Add the third bar series:
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Blue;
            ds.BarWidth    = 0.8;

            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = 1.0 * x;
                ds.LineSeries.Points.Add(new Point(x, y));
            }
            dc.DataList.Add(ds);
            dc.AddBars(cs);
        }