TCHART FROM DATATABLE
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的更多相关文章
- DataTable 转换成 Json的3种方法
在web开发中,我们可能会有这样的需求,为了便于前台的JS的处理,我们需要将查询出的数据源格式比如:List<T>.DataTable转换为Json格式.特别在使用Extjs框架的时候,A ...
- C#中将DataTable导出为HTML的方法
今天我要向大家分享一种将DataTable导出为到HTML格式的方法.有时我们需要HTML格式的输出数据, 以下代码就可以帮助我们达到目的,. 首先,我们要绑定DataTable和 DataGridV ...
- DataTable转换成IList<T>的简单实现
DataTable的无奈 很多时候,我们需要去操作DataTable.但DataTable的操作,实在是太不方便了.Linq?lambda表达式?统统没有... 特别是对现有结果集做进一步筛选,这样的 ...
- 自用的基于Emit的C#下DataTable转实体类方法
之前一直在做WebForm的开发,数据绑定时直接DataTable绑定Gridview很方便,但是最近开始往MVC转,数据列表的传递和页面展示基本上是以List为主,像下面这样,遍历实体类的各个字段去 ...
- jquery dataTable汉化(插件形式)
1.jquery dataTable.js 官网:http://datatables.net/ 中文:http://dt.thxopen.com/ 2.汉化提示信息(放到xx.js中,引入即可) 注: ...
- DataTable与DTO对象的简易转换类
在web开发过程中,有时候为了数据传输的方便,比如:后台需要更新前端的ViewModel,此时我们定义一个与前端ViewModel结构一样的DTO对象,从数据层获取数据后,将数据封装成DTO然后序列化 ...
- asp.net DataTable导出Excel 自定义列名
1.添加引用NPOI.dll 2.cs文件头部添加 using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; using System.IO; 3.代码如 ...
- asp.net dataTable转换成Json格式
/// <summary> /// dataTable转换成Json格式 /// </summary> /// <param name="dt"> ...
- DataTable的orderby有关问题
在网上找了一个在后台重新对DataTable排序的方法(之所以不在数据库是因为我生成的是报表,写了存储过程用的表变量,order by也要用变量,死活拼不起来,sql能力没过关,动态sql也试了) s ...
随机推荐
- LVS群集配置
第一步:网络环境配置内网网段:10.0.0.0/24DR:10.0.0.254rs1:10.0.0.1rs2:10.0.0.2nfs:10.0.0.3 第二步:nfs和web服务搭建 nfs服务器:安 ...
- 图片上传前 压缩,base64图片压缩 Exif.js处理ios拍照倒置等问题
曾写过在前端把图片按比例压缩不失真上传服务器的前端和后台,可惜没有及时做总结保留代码,只记得js利用了base64位压缩和Exif.js进行图片处理,还有其中让我头疼的ios拍照上传后会倒置等诸多问题 ...
- 【python016--序列】
一.列表,元组和字符串的共同点 --都可以通过索引得到每一个元素 --默认索引值总是从0开始 --可以通过分片的方法得到一个范围内的元素的集合 --有很多共同的操作符(重复操作符,拼接操作符.成员关系 ...
- ODAC(V9.5.15) 学习笔记(七)TOraUpdateSQL
名称 类型 说明 DataSet 指向需要执行更新操作的数据集 DeleteObject 当执行删除操作时,通过该属性执行另外一个数据集,由后者来执行更多的删除动作 DeleteSQL TString ...
- 配置vim
VundleVuldle是一个全自动的插件管理器,让我们通过维护插件列表的方式管理插件.它为安装.更新.删除插件提供了方便的命令.在安装Git的情况下(本文不赘述Git的安装),输入命令: git c ...
- ZOJ 3962 Seven Segment Display(数位DP)题解
题意:给一个16进制8位数,给定每个数字的贡献,问你贡献和. 思路:数位DP,想了很久用什么表示状态,看题解说用和就行,其他的都算是比较正常的数位DP. 代码: #include<iostrea ...
- How Flyway works
The easiest scenario is when you point Flyway to an empty database. It will try to locate its schema ...
- Winform异步解决窗体耗时操作(Action专门用于无返回值,Func专门用于有返回值)
http://blog.csdn.net/config_man/article/details/25578767 #region 调用timer控件实时查询开关机时间 private void tim ...
- js数组常用方法,含es5
(1)基本的数组方法 1.join() Array.join()方法将数组中所有元素都转化为字符串并连接在一起,返回最后生成的字符串.可以自己指定分隔的符号,如果不指定,默认使用逗号 var arr ...
- java web 工程更改名字
如图: 将工程名字struts2Project02更改为struts2Project03,步骤如下: 1. 右键工程名字,选中properties,如图 2.更改项目名字 3.第2步已经真正把项目名字 ...