- private void Chart2_6_ReportStart(object sender, EventArgs e)
- {
- string line_code_sql = @"select distinct line_code,getline_name(line_code) linename
- from tbl_static_exceptionmrstatic t
- where t.year = {0}
- and t.speed > 200
- and t.speed < 350
- and t.month in ({1}, {2}, {3})";
- string line_sql = @"select
- t.year , t.month , getline_name(line_code) lineName,round( AVG(TQI_AVG),3) TQI
- from tbl_static_exceptionmrstatic t
- where t.year = {0}
- and t.speed > 200
- and t.speed < 350
- and t.month in ({1}, {2}, {3})
- and line_code='{4}'
- group by t.year, t.month, line_code";
- OracleDataAdapter da = new OracleDataAdapter(string.Format(line_code_sql, 2011, 9, 10, 11), ConfigurationManager.AppSettings["ConnStr"]);
- System.Data.DataSet ds = new System.Data.DataSet();
- da.Fill(ds, "line_code");
- DataTable table = ds.Tables["line_code"];
- System.Data.DataSet ds_lines = new System.Data.DataSet();
- Dictionary<string, string> dicLine = new Dictionary<string, string>();
- for (int i = 0; i < table.Rows.Count; i++)
- {
- string line_code = table.Rows[i]["line_code"].ToString();
- dicLine.Add(line_code, table.Rows[i]["linename"].ToString());
- string str2 = string.Format(line_sql, 2011, 10, 11, 9, line_code);
- OracleDataAdapter da_line = new OracleDataAdapter(str2, ConfigurationManager.AppSettings["ConnStr"]);
- da_line.Fill(ds_lines, line_code);//
- }
- this.chartControl1.DataSource = ds_lines;
- this.chartControl1.Series.Clear();
- for (int i = 0; i < ds_lines.Tables.Count; i++)
- {
- string lineCode = ds_lines.Tables[i].TableName;
- string lineName = dicLine[lineCode];
- DataDynamics.ActiveReports.Chart.Series series = new DataDynamics.ActiveReports.Chart.Series();
- series.Type = DataDynamics.ActiveReports.Chart.ChartType.Line;
- DataPoint[] ps = new DataPoint[ds_lines.Tables[i].Rows.Count];
- //for (int j = 0; j < ds_lines.Tables[i].Rows.Count; j++)
- //{
- // ps[j] = new DataPoint(ds_lines.Tables[i].Rows[j]["month"], ds_lines.Tables[i].Rows[j]["TQI"], false);
- //}
- //series.Points.AddRange(ps);
- this.chartControl1.Series.Add(series);
- this.chartControl1.Series[i].LegendText = lineCode + lineName;
- this.chartControl1.Series[i].ValueMembersY = ds_lines.Tables[lineCode].Columns["TQI"].ColumnName;
- this.chartControl1.Series[i].ValueMemberX = ds_lines.Tables[lineCode].Columns["month"].ColumnName;
- }
- foreach (Legend item in this.chartControl1.Legends)
- {
- item.Visible = true;
- }
- }
复制代码 每个series绑定dataset中一个表的数据,但是绘制出来的图只显示了一条折线如图,急求帮助。。 |