public DataSetSingleSeries(SeriesDataPoints values, AxisLabels labels) { if (values == null) { throw new System.ArgumentNullException("values"); } if (labels == null) { throw new System.ArgumentNullException("labels"); } if (values.Count != labels.Count) { string msg = string.Format("Number of values and labels do not match. {0} values given and {1} labels given", values.Count, labels.Count); throw new System.ArgumentException(msg); } this.DataPoints = values; this.XAxisLabels = labels; }
public ChartDataSingleSeries(SeriesDataPoints values, SeriesLabels labels) { if (values == null) { throw new System.ArgumentNullException("values"); } if (labels == null) { throw new System.ArgumentNullException("labels"); } if (values.Length != labels.Length) { string msg = string.Format("Number of values and labels do not match. {0} values given and {1} labels given", values.Length, labels.Length); throw new System.ArgumentException(msg); } this.Values = values; this.XAxisLabels = labels; }
public DataSetSingleSeries() { this.DataPoints = new SeriesDataPoints(); this.XAxisLabels = new AxisLabels(); }
public static DataSetMultiSeries DataTableToChartDataSet(System.Data.DataTable dt, int category_col, int val_col, int series_col, bool exclude_dbnull_values) { var dt_cat_col = dt.Columns[category_col]; var dt_val_col = dt.Columns[val_col]; var dt_ser_col = dt.Columns[series_col]; CheckCatCol(dt_cat_col); CheckValCol(dt_val_col); CheckSerCol(dt_ser_col); var ser_to_values = new Dictionary<string, Dictionary<string,double>>(); var cats = new HashSet<string>(); 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; } cats.Add(cat); } foreach (System.Data.DataRow row in dt.Rows) { var items = row.ItemArray; string cat = (string) items[category_col]; string ser = (string) items[series_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); if (!ser_to_values.ContainsKey(ser)) { ser_to_values[ser] = new Dictionary<string, double>(cats.Count); } var ser_list = ser_to_values[ser]; ser_list[cat]=val; } var list_of_series = new List<SeriesDataPoints>(); foreach (var ser_list in ser_to_values.Values) { var sdp = new SeriesDataPoints(); foreach (string cat in cats) { // Try to find a value for each category if (ser_list.ContainsKey(cat)) { double v = ser_list[cat]; var dp = new DataPoint(v); sdp.Add(dp); } else { double v = 0.0; var dp = new DataPoint(v); sdp.Add(dp); } } } var axislabels = new WebCharting.Data.AxisLabels(cats); var cd = new DataSetMultiSeries(list_of_series, axislabels); return cd; }