c# 使用 Tchart控件之数据绑定

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/wpf123/archive/2011/07/07/2100447.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值