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 ...
随机推荐
- 浅析alsa声卡驱动snd_interval结构体openmin,openmax和integer含义
// openmin和openmax表示开集,如果2个全为1,那么就表示,range范围为(min,max)即2个开区间// openmin为1,openmax为0,range范围为(min,max] ...
- CSS的再深入2(更新中···)
在上一章中,我们又引出了一个知识点: margin的问题 margin:0 auto:(上下为0,左右自适应)会解决元素的居中问题(auto 自适应)前提是给这个元素设置width 同时,我们又要学习 ...
- sqlitestudio
SQLite数据库的特性 特点: 1.轻量级2.独立性,没有依赖,无需安装3.隔离性 全部在一个文件夹系统4.跨平台 支持众多操作系统5.多语言接口 支持众多编程语言6.安全性 事物,通过独占性和共享 ...
- linux基础之vim编辑器
vi : Visual Interface vim : VI Improved : VI的基础加上一些有用的插件 vim编辑器: 文本编辑器, 字处理器, 全屏编辑器, 模式化编辑器 vim的模式有三 ...
- Optical Flow related Tutorials
Optical Flow related Tutorials 2017-04-01 10:50:55 Reference: 1. http://blog.csdn.net/carson2005/art ...
- [RabbitMQ学习笔记] - 初识RabbitMQ
RabbitMQ是一个由erlang开发的AMQP的开源实现. 核心概念 Message 消息,消息是不具名的,它由消息头和消息体组成,消息体是不透明的,而消息头则由 一系列的可选属性组成,这些属性包 ...
- Hadoop【单机安装-测试程序WordCount】
Hadoop程序说明,就是创建一个文本文件,然后统计这个文本文件中单词出现过多少次! (MapReduce 运行在本地 启动JVM ) 第一步 创建需要的文件目录,然后进入该文件中进行编辑 ...
- Win10远程桌面可能是由于CredSSP加密Oracle修正
win10更新1083之后,远程桌面就会连接失败,显示如下: 根据微软官方的说法是更改了安全策略: https://support.microsoft.com/zh-cn/help/4093492/c ...
- 前端UI框架总结
H-ui 前端框架 架起设计与后端的桥梁轻量级前端框架,简单免费,兼容性好,服务中国网站. 官网:http://www.h-ui.net/H-ui.admin.shtml github下载:https ...
- SQLServer代理新建或者编辑作业报错
SQLServer代理新建或者编辑作业的时候报错如下 错误信息: 标题: Microsoft SQL Server Management Studio------------------------- ...