c# 使用 Tchart控件之数据绑定
2011-07-07 20:47
295 查看
google了一把tchart控件,看到许多都没有讲到数据绑定的。没事就做个简单的demo。不在赘述,如下:
tChart1.Header.Text = "报告测试";
tChart1.Aspect.View3D = false;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM-dd";////把X坐标轴刻度设置成时间类型,Axes是坐标轴的意思,Bottom是X轴,也可以选择其他轴
tChart1.Axes.Bottom.Labels.MultiLine = true;
//tChart1.Axes.Bottom.SetMinMax(DateTime.Now.AddYears(8), DateTime.Now);
line1.Title = "曲线名字";
line1.Color = Color.Red;
line2.Color = Color.SeaGreen;
line3.Color = Color.Yellow;
tChart1.Legend.CheckBoxes = true;
string constr = "Data Source=.;Initial Catalog=OnlineTestData_Lite;Integrated Security=True";
SqlConnection con = new SqlConnection(constr);
SqlDataAdapter da = new SqlDataAdapter("select ID,TestDateTime,ueff_0,ueff_1,ueff_2 from Process_Data where testdatetime > '2010-01-01 22:22:22'", con);
DataTable dt = new DataTable();
da.Fill(dt);
line1.DataSource = dt;
line1.XValues.DataMember = "TestDateTime";
line1.YValues.DataMember = "ueff_1";
line1.LabelMember = "TestDateTime";
line2.DataSource = dt;
line2.XValues.DataMember = "TestDateTime";
line2.YValues.DataMember = "ueff_2";
line2.LabelMember = "TestDateTime";
line3.DataSource = dt;
line3.XValues.DataMember = "TestDateTime";
line3.XValues.DateTime = true;
line3.YValues.DataMember = "ueff_0";
line3.LabelMember = "TestDateTime";
//调用
cursorTool1_Change(tChart1, new Steema.TeeChart.Tools.CursorChangeEventArgs());
效果图如下所示:
tChart1.Header.Text = "报告测试";
tChart1.Aspect.View3D = false;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM-dd";////把X坐标轴刻度设置成时间类型,Axes是坐标轴的意思,Bottom是X轴,也可以选择其他轴
tChart1.Axes.Bottom.Labels.MultiLine = true;
//tChart1.Axes.Bottom.SetMinMax(DateTime.Now.AddYears(8), DateTime.Now);
line1.Title = "曲线名字";
line1.Color = Color.Red;
line2.Color = Color.SeaGreen;
line3.Color = Color.Yellow;
tChart1.Legend.CheckBoxes = true;
string constr = "Data Source=.;Initial Catalog=OnlineTestData_Lite;Integrated Security=True";
SqlConnection con = new SqlConnection(constr);
SqlDataAdapter da = new SqlDataAdapter("select ID,TestDateTime,ueff_0,ueff_1,ueff_2 from Process_Data where testdatetime > '2010-01-01 22:22:22'", con);
DataTable dt = new DataTable();
da.Fill(dt);
line1.DataSource = dt;
line1.XValues.DataMember = "TestDateTime";
line1.YValues.DataMember = "ueff_1";
line1.LabelMember = "TestDateTime";
line2.DataSource = dt;
line2.XValues.DataMember = "TestDateTime";
line2.YValues.DataMember = "ueff_2";
line2.LabelMember = "TestDateTime";
line3.DataSource = dt;
line3.XValues.DataMember = "TestDateTime";
line3.XValues.DateTime = true;
line3.YValues.DataMember = "ueff_0";
line3.LabelMember = "TestDateTime";
//调用
cursorTool1_Change(tChart1, new Steema.TeeChart.Tools.CursorChangeEventArgs());
效果图如下所示:
相关文章推荐
- c# 使用 Tchart控件之数据绑定
- C# 程序中如何向(DEV)ComboBoxEdit控件中添加下拉列表的值不使用数据绑定,就是使用代码添加
- C# List,String Array 绑定到数据控件上
- 使用DataList控件绑定数据并实现分页
- 使用objectdatasource结合数据绑定控件进行简单三层架构的开发
- C# treeview 控件动态绑定数据
- 使用Linq to SQL实现基本的增、删、改、查及绑定控件(C#)
- 地磅称量系统之(37~39) 直接向数据库的数据表WtBill添加测试数据以及绑定用户控件和使用编码的方式控制dataGridView控件的每列属性和添加数据数据库的表中不存在的字段(非绑定列)
- C#中DataGridView控件的数据绑定
- 什么时候使用哪个数据绑定控件(asp.net)
- .NET 使用GridView控件绑定数据源其他操作(查询相关数据,而不是显示全数据)
- C#中的DataGridView控件(WIN FORM),数据绑定与数据联动
- 数据绑定(Databind)与 repeater 控件的使用。
- C# .NET treeView(树形控件)绑定数据的通用方法 (精)
- 微软图表控件使用初探--数据绑定(交叉表)(转)
- ASP.NET数据绑定GridView控件使用技巧
- C#新手之控件数据绑定
- ASP.NET中DropDownList控件的简单使用--DDL绑定数据库表中值,选择DDL中值直接检索数据
- ASP.NET中DropDownList控件的简单使用--DDL绑定数据库表中值,选择DDL中值直接检索数据
- asp.net下的“Eval()、XPath() 和 Bind() 这类数据绑定方法只能在数据绑定控件的上下文中使用。”错误的一个可能的成因