博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c# 使用 Tchart控件之数据绑定
阅读量:7014 次
发布时间:2019-06-28

本文共 1425 字,大约阅读时间需要 4 分钟。

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());
效果图如下所示:

2011070720453327.jpg

转载于:https://www.cnblogs.com/zhangtao/archive/2011/07/07/2347544.html

你可能感兴趣的文章
寄存器变量 extern 外部变量 外部函数
查看>>
IT思想类智力题
查看>>
Git 版本导致 clone 故障
查看>>
【C++】Geekband - 专题一:new和delete的整理
查看>>
H2O Driverless AI
查看>>
winform GDI基础(四)简单截屏
查看>>
WEB前端开发规范文档
查看>>
最大熵模型原理
查看>>
Mysql 用户和权限管理
查看>>
python内建函数
查看>>
Sencha-数据-Proxy(代理) (官网文档翻译25)
查看>>
[C#]richtextbox实现拖放
查看>>
Python ImportError: cannot import name *
查看>>
Hadoop生态圈-Flume的组件之拦截器与选择器
查看>>
Java基础-SSM之mybatis多对多关联
查看>>
Android微信支付SDK开发
查看>>
[Android Pro] 横竖屏切换时,禁止activity重新创建,android:configChanges="keyboardHidden|orientation" 不起作用...
查看>>
上学路线
查看>>
相对路径 System.Web HttpServerUtilityBase Server.MapPath("~/")
查看>>
【转】Spring中事务与aop的先后顺序问题
查看>>