private static bool paintChart(DataTable dtLine1, string strLineName, string strXTitle, string strState, string strTitle, ZedGraph.ZedGraphControl zedChart) { try { //lblInfo.Text=strTitle; ZedGraph.Demo.DateAxisSampleDemo demo = new ZedGraph.Demo.DateAxisSampleDemo(); demo.m_dtLine1 = dtLine1; demo.m_dtLine2 = new DataTable(); //第一条线名称 demo.m_strLine1Name = strLineName; //第二条线名称 demo.m_strLine2Name = ""; demo.m_strState = strState; demo.m_strTitle = strTitle; demo.m_xAxisTitle = strXTitle; demo.initialDateAxis(zedChart); if (demo == null) { return(false); } return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } }
private static bool paintChartMonth(DataTable dtLine1,string strLineName,string strXTitle,string strState,string strTitle,ZedGraph.ZedGraphControl zedChart) { try { //lblInfo.Text=strTitle; ZedGraph.Demo.DateAxisSampleDemo demo = new ZedGraph.Demo.DateAxisSampleDemo(); demo.m_dtLine1 =dtLine1; demo.m_dtLine2=new DataTable(); //��һ�������� demo.m_strLine1Name=strLineName; //�ڶ��������� demo.m_strLine2Name=""; demo.m_strState=strState; demo.m_strTitle=strTitle; demo.m_xAxisTitle=strXTitle; demo.initialDateAxisMonth(zedChart); if ( demo == null ) return false; return true; } catch(Exception ex) { cSaveErr.CSaveErr.msgboxErr(ex.ToString()); return false; } }
//绘制图表 public bool PaintFrm(string strWellNo) { try { string strFrom = String.Format("{0}-{1}-{2}", this.dtFrom.Value.Year.ToString(), this.dtFrom.Value.Month.ToString(), this.dtFrom.Value.Day.ToString()); string strTo = String.Format("{0}-{1}-{2}", this.dtTo.Value.Year.ToString(), this.dtTo.Value.Month.ToString(), this.dtTo.Value.Day.ToString()); string strSql = String.Format("select depName from tbWell where wellNo='{0}'", strWellNo); string strDepName = CDBConnection.ExecuteScalar(strSql); this.lblInfo.Text = String.Format("水井编号:{0} 单位名称:{3} 日期:{1} 至 {2}", strWellNo, strFrom, strTo, strDepName); DataTable dtLine1 = new DataTable(); DataTable dtLine2 = new DataTable(); if (this.m_strDrawLine1Sql != "") { //查询第一条线的sql语句 strSql = this.m_strDrawLine1Sql; DataTable dt = new DataTable(); CDBConnection.getDataTable(ref dt, strSql, "tbData"); dtLine1 = dt; } if (this.m_strDrawLine2Sql != "") { //查询第二条线的sql语句 strSql = this.m_strDrawLine2Sql; DataTable dt = new DataTable(); CDBConnection.getDataTable(ref dt, strSql, "tbData"); dtLine2 = dt; } ZedGraph.Demo.DateAxisSampleDemo demo = new ZedGraph.Demo.DateAxisSampleDemo(); demo.m_dtLine1 = dtLine1; demo.m_strTitle = ""; demo.m_dtLine2 = dtLine2; //第一条线名称 demo.m_strLine1Name = this.m_strColTitle1; //第二条线名称 demo.m_strLine2Name = this.m_strColTitle2; if (strFrom != strTo) { //绘图 demo.m_strState = "month"; } else { //绘图 demo.m_strState = "Day"; } demo.initialDateAxis(); if (demo == null) { return(false); } this.tabChart.TabPages[0].Controls.Clear(); this.tabChart.TabPages[0].Controls.Add(this.lblInfo); this.tabChart.TabPages[0].Controls.Add(demo.ZedGraphControl); //demo.ZedGraphControl.Top=this.label1.Top+this.label1.Height; demo.ZedGraphControl.Top = 10; demo.ZedGraphControl.Left = 10; demo.ZedGraphControl.Width = tabChart.Width - 20; demo.ZedGraphControl.Height = tabChart.Height - 40; demo.ZedGraphControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; //this.Text = TitlePrefix + demo.Title; //descriptionBox.Text = demo.Description; // tell the control to rescale itself demo.ZedGraphControl.AxisChange(); // redraw the entire form this.Invalidate(); return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } }