zoukankan      html  css  js  c++  java
  • 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());

    效果图如下所示:

  • 相关阅读:
    百度员工揭秘百度八月最新优化的算法《绝密资料》
    解决IE8兼容问题只需要一句简短的代码
    选择Xen与OpenVZ哪种虚拟机做的VPS比较好?
    Windows VPS出现磁盘不足解决方法
    JiaSale 购物按钮 WordPress 插件:让你博客瞬间变成电商网站
    tb
    滚动marquee语法
    Change the marquee directions on button click left and right
    iOS多线程 GCD常见用法
    swift 中关于open ,public ,fileprivate,private ,internal,修饰的说明
  • 原文地址:https://www.cnblogs.com/wpf123/p/2100447.html
Copyright © 2011-2022 走看看