private void Lb_csrq_SelectionChanged(object sender, SelectionChangedEventArgs e) { DB_XSPM_MONTH xspm = (DB_XSPM_MONTH)lb_csrq.SelectedItem; tb_right_csrq.Text = xspm.CSRQ; create_chart(); }
private void create_chart() { var chart = (Chart)wfh.Child; chart.Series.Clear(); chart.ChartAreas.Clear(); //ChartArea ChartArea chartArea = new ChartArea(); chartArea.Axes[0].MajorGrid.Enabled = false; chartArea.Axes[1].MajorGrid.Enabled = false; chartArea.AxisX.IsReversed = true; chartArea.AxisX.Title = "层位"; chartArea.AxisY.Title = "注入百分数"; chartArea.AxisX.Interval = 1; chartArea.AxisX.ScaleView.Size = 10; chart.ChartAreas.Add(chartArea); //Series Series series = new Series(); series.ChartType = SeriesChartType.Bar; series.IsValueShownAsLabel = true; DB_XSPM_MONTH model = (DB_XSPM_MONTH)lb_csrq.SelectedItem; if (model == null) { model = new DB_XSPM_MONTH() { CSRQ = bll.tpjing.csrq } } ; List <DB_XSPM_MONTH> list = bll.oc_xspm.Where(p => p.CSRQ == model.CSRQ).ToList(); if (list.Count == 0) { return; } for (int i = 0; i < list.Count(); i++) { DataPoint point = new DataPoint(); point.XValue = i; point.YValues = new double[] { list[i].ZRBFS }; point.AxisLabel = string.Format("{0} {1}/{2} ({3})", list[i].YCZ, list[i].XCH, list[i].JSXH, list[i].YXHD); point.Label = list[i].ZRBFS.ToString(); series.Points.Add(point); } chart.Series.Add(series); }
/// <summary> /// 初始化吸水剖面 /// </summary> private void init_oc_xspm() { oc_xspm.Clear(); StringBuilder sql = new StringBuilder(); sql.AppendFormat("select * from xspm_month where ZT=0 and jh = \"{0}\"", tpjing.jh); DataTable dt = DbHelperOleDb.Query(sql.ToString()).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { DB_XSPM_MONTH model = new DB_XSPM_MONTH(); model.JH = Unity.ToString(dt.Rows[i]["jh"]); model.CSRQ = Unity.DateTimeToString(dt.Rows[i]["csrq"], "yyyy-MM-dd"); model.YCZ = Unity.ToString(dt.Rows[i]["ycz"]); model.XCH = Unity.ToString(dt.Rows[i]["xch"]); model.JSXH = Unity.ToInt(dt.Rows[i]["xfch"]); model.JDDS1 = Unity.ToDouble(dt.Rows[i]["jdds1"]); model.ZRBFS = Unity.ToDouble(dt.Rows[i]["zrbfs"]); oc_xspm.Add(model); } }