日期:2014-05-20 浏览次数:20824 次
string myConnectionString = ReportForm.Properties.Settings.Default.CEC710ConnectionString; string mySelectQuery="SELECT vol_va,vol_vb,vol_vc,cur_ia,cur_ib,cur_ic,opertime FROM [AmmeterData103]"; SqlConnection myConnection = new SqlConnection(myConnectionString); SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection); // Set chart data source chart1.DataSource = myCommand; chart1.BorderlineWidth = 3; // Set series members names for the X and Y values chart1.Series["A相电压"].XValueMember = "OperTime"; chart1.Series["A相电压"].YValueMembers = "vol_va"; chart1.Series["B相电压"].XValueMember = "OperTime"; chart1.Series["B相电压"].YValueMembers = "vol_vb"; chart1.Series["C相电压"].XValueMember = "OperTime"; chart1.Series["C相电压"].YValueMembers = "vol_vc"; chart1.Series["A相电流"].XValueMember = "OperTime"; chart1.Series["A相电流"].YValueMembers = "cur_ia"; chart1.Series["B相电流"].XValueMember = "OperTime"; chart1.Series["B相电流"].YValueMembers = "cur_ib"; chart1.Series["C相电流"].XValueMember = "OperTime"; chart1.Series["C相电流"].YValueMembers = "cur_ic"; // Data bind to the selected data source chart1.DataBind(); foreach (Series s in chart1.Series) { s.ChartType = SeriesChartType.Spline; }