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 ...
随机推荐
- tftp 传输文件
tftp 服务方便文件传输,但是没有理清的话,容易传输错误. -g 表示下载文件 (get) -p 表示上传文件 (put)-l 表示本地文件名 (local file) -r 表示远程主机的文件名 ...
- JavaScript中数组的排序方法:1.冒泡排序 2.选择排序
//1.选择排序: //从小到大排序:通过比较首先选出最小的数放在第一个位置上,然后在其余的数中选出次小数放在第二个位置上,依此类推,直到所有的数成为有序序列. var arr2=[19, 8, ...
- CEF 文件下载
转载:https://blog.csdn.net/liuyan20092009/article/details/53819473?locationNum=6&fps=1 转载:https:// ...
- WebSocket、Socket
https://www.cnblogs.com/jingmoxukong/p/7755643.html#undefined WebSocket 详解教程 WebSocket介绍,与Socket的区别 ...
- Flask学习【第10篇】:自定义Form组件
wtforms源码流程 实例化流程分析 1 # 源码流程 2 1. 执行type的 __call__ 方法,读取字段到静态字段 cls._unbound_fields 中: meta类读取到cls._ ...
- git用法-打补丁【转】
本文转载自:https://www.cnblogs.com/yandufeng/p/5580765.html 1. git cherry-pick 作用:从一个branch上选择一个commit,添加 ...
- loj#2305. 「NOI2017」游戏 2-sat
链接 https://loj.ac/problem/2305 https://www.luogu.org/problemnew/show/P3825 思路 3-sat神马的就不要想了,NP问题 除去x ...
- 论文笔记:A Review on Deep Learning Techniques Applied to Semantic Segmentation
A Review on Deep Learning Techniques Applied to Semantic Segmentation 2018-02-22 10:38:12 1. Intr ...
- mybatis中mysql转义讲解
本文为博主原创,未经允许不得转载: 在mybatis中写sql的时候,遇到特殊字符在加载解析的时候,会进行转义,所以在mybatis中 写sql语句的时候,遇到特殊字符进行转义处理. 需要注意的是,转 ...
- Jenkins参数化构建(三)之 Jenkins从文件中读取运行参数
安装Extended Choice Parameter插件 选择‘参数化构建过程’ maven command line中进行引用 clean test -DsuiteXmlFile=src/main ...