Beispiel #1
0
        public static DataSetSingleSeries DataTableToChartDataSet(System.Data.DataTable dt, 
                                                                    int category_col,
                                                                  int val_col, bool exclude_dbnull_values)
        {
            var dt_cat_col = dt.Columns[category_col];
            var dt_val_col = dt.Columns[val_col];

            CheckCatCol(dt_cat_col);
            CheckValCol(dt_val_col);

            var cd = new DataSetSingleSeries();

            foreach (System.Data.DataRow row in dt.Rows)
            {
                var items = row.ItemArray;
                string cat = (string) items[category_col];
                object o = items[val_col];

                // exclude dbnull values
                var ot = o.GetType();
                if (exclude_dbnull_values && ot==typeof(System.DBNull))
                {
                    continue;
                }

                double val = GetVal(dt_val_col, o);
                var dp = new DataPoint(val);
                cd.Add(dp, cat);
            }

            return cd;
        }
Beispiel #2
0
        public static DataSetSingleSeries DataTableToChartDataSet(System.Data.DataTable dt,
                                                                  int category_col,
                                                                  int val_col, bool exclude_dbnull_values)
        {
            var dt_cat_col = dt.Columns[category_col];
            var dt_val_col = dt.Columns[val_col];

            CheckCatCol(dt_cat_col);
            CheckValCol(dt_val_col);

            var cd = new DataSetSingleSeries();

            foreach (System.Data.DataRow row in dt.Rows)
            {
                var    items = row.ItemArray;
                string cat   = (string)items[category_col];
                object o     = items[val_col];

                // exclude dbnull values
                var ot = o.GetType();
                if (exclude_dbnull_values && ot == typeof(System.DBNull))
                {
                    continue;
                }

                double val = GetVal(dt_val_col, o);
                var    dp  = new DataPoint(val);
                cd.Add(dp, cat);
            }

            return(cd);
        }