예제 #1
0
        public void FillChartData(tblObject content, System.Data.IDataReader reader, string xFieldName, Dictionary <int, string> yFieldNames, List <ChartSeries> series, Chart chart)
        {
            SetSeriesSchema(reader, yFieldNames, xFieldName, series, chart);

            while (reader.Read())
            {
                int i = 0;
                foreach (KeyValuePair <int, string> yField in yFieldNames)
                {
                    string yFieldName = yField.Value.ToString();
                    object ob         = string.IsNullOrEmpty(yFieldName) ? reader[yField.Key] : reader[yFieldName];
                    object o          = ConvertChartYValue(ob);
                    //object o = (ob is DBNull) ? null : ConvertChartYValue(ob);
                    series[i].data.Add(o);
                    Type type = reader.GetFieldType(reader.GetOrdinal(yFieldName));

                    if (!(o is DBNull) && IsNumeric(type))
                    {
                        try
                        {
                            if (!content.Neg && Convert.ToDecimal(o) < 0)
                            {
                                content.Neg = true;
                            }
                        }
                        catch { }
                    }
                    i++;
                }

                content.xAxis.Add(ConvertChartXValue(reader[xFieldName]));
            }
        }
예제 #2
0
 public void SetChartProperties(Chart chart, tblObject content, string xFieldName, Dictionary <int, string> yFieldNames, List <ChartSeries> series)
 {
     content.series    = series;
     content.Title     = chart.Name;
     content.SubTitle  = chart.SubTitle;
     content.Type      = chart.ChartType.ToString().ToLower();
     content.XTitle    = string.IsNullOrEmpty(chart.XTitle) ? xFieldName : chart.XTitle;
     content.YTitle    = string.IsNullOrEmpty(chart.YTitle) ? string.Join(",", yFieldNames.Values.ToArray()) : chart.YTitle;
     content.Height    = (chart.Height == 0) ? "340" : chart.Height.ToString();
     content.ShowTable = chart.ShowTable;
 }