- C# code
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; }
我的数据库的AmmeterData103表里有多个字段,但我这里画图只需要三个电压,三个电流,请问如何画到一张图中呢?
------解决方案--------------------------------------------------------
谢谢楼主分享!
有机会请楼主给点测试数据,也感觉一下楼主的喜悦!
------解决方案--------------------------------------------------------
路过拿分...