using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;

using System.Windows.Forms;

namespace Steema.TeeChart.Samples
{
public class DataConnect : Steema.TeeChart.Samples.BaseForm
{
private System.ComponentModel.IContainer components = null;

//variables
private DataTable sourceTable;
private DataColumn colXData;
private DataColumn colYData;
private DataColumn colDesc;
private Steema.TeeChart.Styles.Bar barSeries1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private Steema.TeeChart.Tools.GridBand gridBand1;
private DataColumn colColor;

public DataConnect()
{
// This call is required by the Windows Form Designer.
InitializeComponent();
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.barSeries1 = new Steema.TeeChart.Styles.Bar();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.gridBand1 = new Steema.TeeChart.Tools.GridBand();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(592, 73);
this.textBox1.Text = "This example demonstrates how to connect a TeeChart XY Series to a DataTable at r" +
"untime.\r\n\r\nCheck/uncheck the checkboxes to include/exclude the X value and Label" +
" DataTable fields from the Series.";
//
// panel1
//
this.panel1.Controls.Add(this.checkBox2);
this.panel1.Controls.Add(this.checkBox1);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(592, 31);
//
// tChart1
//
//
// tChart1.Aspect
//
this.tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
this.tChart1.Aspect.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
//
// tChart1.Header
//
this.tChart1.Header.Lines = new string[] {
"tChart1"};
this.tChart1.Location = new System.Drawing.Point(0, 104);
this.tChart1.Name = "tChart1";
//
// tChart1.Panel
//
//
// tChart1.Panel.Brush
//
this.tChart1.Panel.Brush.Color = System.Drawing.Color.FromArgb(((System.Byte)(254)), ((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
this.tChart1.Series.Add(this.barSeries1);
this.tChart1.Size = new System.Drawing.Size(592, 264);
this.tChart1.Tools.Add(this.gridBand1);
//
// tChart1.Walls
//
//
// tChart1.Walls.Back
//
//
// tChart1.Walls.Back.Brush
//
this.tChart1.Walls.Back.Brush.Color = System.Drawing.Color.FromArgb(((System.Byte)(254)), ((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
this.tChart1.Walls.Back.Transparent = false;
//
// tChart1.Walls.Bottom
//
//
// tChart1.Walls.Bottom.Pen
//
this.tChart1.Walls.Bottom.Pen.Visible = false;
this.tChart1.Walls.Bottom.Size = 5;
//
// tChart1.Walls.Left
//
//
// tChart1.Walls.Left.Pen
//
this.tChart1.Walls.Left.Pen.Visible = false;
this.tChart1.Walls.Left.Size = 5;
//
// barSeries1
//
//
// barSeries1.Brush
//
this.barSeries1.Brush.Color = System.Drawing.Color.Red;
this.barSeries1.Cursor = System.Windows.Forms.Cursors.Cross;
//
// barSeries1.Marks
//
//
// barSeries1.Marks.Symbol
//
//
// barSeries1.Marks.Symbol.Shadow
//
this.barSeries1.Marks.Symbol.Shadow.Height = 1;
this.barSeries1.Marks.Symbol.Shadow.Visible = true;
this.barSeries1.Marks.Symbol.Shadow.Width = 1;
this.barSeries1.Title = "barSeries1";
//
// barSeries1.XValues
//
this.barSeries1.XValues.DataMember = "X";
this.barSeries1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
//
// barSeries1.YValues
//
this.barSeries1.YValues.DataMember = "Bar";
//
// checkBox1
//
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.checkBox1.Location = new System.Drawing.Point(16, 6);
this.checkBox1.Name = "checkBox1";
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "Include &Labels";
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// checkBox2
//
this.checkBox2.Checked = true;
this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.checkBox2.Location = new System.Drawing.Point(120, 6);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(120, 24);
this.checkBox2.TabIndex = 1;
this.checkBox2.Text = "Include &XValues";
this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
//
// gridBand1
//
this.gridBand1.Axis = this.tChart1.Axes.Left;
//
// gridBand1.Band1
//
this.gridBand1.Band1.Color = System.Drawing.Color.FromArgb(((System.Byte)(127)), ((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
//
// gridBand1.Band2
//
this.gridBand1.Band2.Color = System.Drawing.Color.FromArgb(((System.Byte)(127)), ((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
//
// DataConnect
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(592, 368);
this.Name = "DataConnect";
this.Load += new System.EventHandler(this.DataConnect_Load);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

private void DataConnect_Load(object sender, System.EventArgs e)
{
tChart1.Axes.Bottom.Labels.Style=AxisLabelStyle.Value;
CreateTable();
LoadData();
}

private void CreateTable()
{
Random r=new Random(255);

// Create DataTable
sourceTable = new DataTable("sourceTable");
colXData = new DataColumn("XData",Type.GetType("System.Double"));
colYData = new DataColumn("YData",Type.GetType("System.Double"));
colDesc = new DataColumn("Desc",Type.GetType("System.String"));
colColor = new DataColumn("Color",Type.GetType("System.Object"));

sourceTable.Columns.Add(colXData);
sourceTable.Columns.Add(colYData);
sourceTable.Columns.Add(colDesc);
sourceTable.Columns.Add(colColor);

// Add table items.
DataRow NewRow;
double lastVal=0;
for(int i = 0; i <10; i++)
{
Color cc=Color.FromArgb(r.Next(255),r.Next(255),r.Next(255));
NewRow = sourceTable.NewRow();
NewRow["Desc"] = "Label"+i.ToString();
NewRow["XData"] = lastVal;
NewRow["YData"] = r.Next(10);
NewRow["Color"] = cc;
sourceTable.Rows.Add(NewRow);
lastVal=lastVal+5+r.Next(5);
}

}

private void LoadData()
{
tChart1[0].Clear();

//include Labels
if (checkBox1.Checked)
tChart1[0].LabelMember=colDesc.ToString();
else
tChart1[0].LabelMember="";

//include XValues
if (checkBox2.Checked)
tChart1[0].XValues.DataMember=colXData.ToString();
else
tChart1[0].XValues.DataMember="";

tChart1[0].ColorMember=colColor.ToString();
tChart1[0].YValues.DataMember=colYData.ToString();
tChart1[0].DataSource=sourceTable;
}

private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
LoadData();
tChart1[0].CheckDataSource();
}

private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
LoadData();
tChart1[0].CheckDataSource();
}

}
}

TCHART FROM DATATABLE的更多相关文章

  1. DataTable 转换成 Json的3种方法

    在web开发中,我们可能会有这样的需求,为了便于前台的JS的处理,我们需要将查询出的数据源格式比如:List<T>.DataTable转换为Json格式.特别在使用Extjs框架的时候,A ...

  2. C#中将DataTable导出为HTML的方法

    今天我要向大家分享一种将DataTable导出为到HTML格式的方法.有时我们需要HTML格式的输出数据, 以下代码就可以帮助我们达到目的,. 首先,我们要绑定DataTable和 DataGridV ...

  3. DataTable转换成IList<T>的简单实现

    DataTable的无奈 很多时候,我们需要去操作DataTable.但DataTable的操作,实在是太不方便了.Linq?lambda表达式?统统没有... 特别是对现有结果集做进一步筛选,这样的 ...

  4. 自用的基于Emit的C#下DataTable转实体类方法

    之前一直在做WebForm的开发,数据绑定时直接DataTable绑定Gridview很方便,但是最近开始往MVC转,数据列表的传递和页面展示基本上是以List为主,像下面这样,遍历实体类的各个字段去 ...

  5. jquery dataTable汉化(插件形式)

    1.jquery dataTable.js 官网:http://datatables.net/ 中文:http://dt.thxopen.com/ 2.汉化提示信息(放到xx.js中,引入即可) 注: ...

  6. DataTable与DTO对象的简易转换类

    在web开发过程中,有时候为了数据传输的方便,比如:后台需要更新前端的ViewModel,此时我们定义一个与前端ViewModel结构一样的DTO对象,从数据层获取数据后,将数据封装成DTO然后序列化 ...

  7. asp.net DataTable导出Excel 自定义列名

    1.添加引用NPOI.dll 2.cs文件头部添加 using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; using System.IO; 3.代码如 ...

  8. asp.net dataTable转换成Json格式

    /// <summary> /// dataTable转换成Json格式 /// </summary> /// <param name="dt"> ...

  9. DataTable的orderby有关问题

    在网上找了一个在后台重新对DataTable排序的方法(之所以不在数据库是因为我生成的是报表,写了存储过程用的表变量,order by也要用变量,死活拼不起来,sql能力没过关,动态sql也试了) s ...

随机推荐

  1. You have new mail in /var/spool/mail/root

    centos7.5 查看邮件的方式: [root@web01 code]# yum -y install mailx #安装mailx [root@web01 code]# mail #执行mail命 ...

  2. python操作串口

    import serial test = serial.Serial("COM1",115200)#这里就已经打开了串口 print(test.portstr) test.writ ...

  3. topcoder srm 410 div1

    problem1 link 不包含$gridConnections$ 的联通块一定是连在所有包含$gridConnections$的联通块中最大的那一块上. import java.util.*; i ...

  4. Linux使用——Linux命令——CentOS7防火墙使用

    注意:设置防火墙需要使用具有root权限的用户进入: CentOS 7.0默认使用的是firewall作为防火墙: CentOS 7.0使用systemctl来管理服务和程序,包括了service和c ...

  5. Python 解析 XML 文件生成 HTML

    XML文件result.xml,内容如下: <ccm> <metric> <complexity>1</complexity> <unit> ...

  6. SpringBoot 使用jwt进行身份验证

    这里只供参考,比较使用jwt方式进行身份验证感觉不好,最不行的就是不能退出 登陆时设定多长过期时间,只能等这个时间过了以后才算退出,服务端只能验证请求过来的token是否通过验证 Code: /** ...

  7. FJNU2018低程F jq解救fuls (贪心乱搞)题解

    题目描述 一天fuls被邪恶的"咕咕咕"抓走了,jq为了救fuls可谓是赴汤蹈火,费了九牛二虎之力才找到了"咕咕咕"关押fuls的地方. fuls被关在一个机关 ...

  8. SSM项目问题中遇到 ArrayList添加元素的问题

    记录项目开发中 一次有趣的debug经历 本来是在做单元测试的,但是发现如下代码 有问题.. ProductCategory p = new ProductCategory(); for (int i ...

  9. mysql重要sql小记

    mysql -hip -uuser -p -A DB -e '[sql]' | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' & ...

  10. parent获取子元素以及自身元素

    innerHTML 设置或获取位于对象起始和结束标签内的 HTML outerHTML 设置或获取对象及其内容的 HTML 形式 innerText 设置或获取位于对象起始和结束标签内的文本 oute ...