My Company's information security rule is too rigid, I can't export any
Files to outside site.
So.. I'm posting about making temporary SQL DB and Chart Drawing Full Source Code for Your reproducing.
1. Make SQL DB Table
(We use MS SQL Express 2005 )
/*Create Table*/
USE [tempdb]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TChartTable](
[EXTKEY] [int] IDENTITY(1,1) NOT NULL,
[TKINTIME] [datetime] NULL,
[VALUE] [float] NULL,
[TABLEIDX] [int] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
/* Test Data Insert */
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,1,getdate()),0.001,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,5,getdate()),0.003,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(m,1,getdate()),0.009,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,8,getdate()),0.02,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,3,getdate()),0.0051,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,11,getdate()),0.04,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,20,getdate()),0.007,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,16,getdate()),0.004,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,26,getdate()),0.011,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,2,getdate()),0.003,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,10,getdate()),0.011,1)
insert into [dbo].[TChartTable](TKINTIME,VALUE,TABLEIDX)
values(dateadd(d,15,getdate()),0.006,1)
2. Chart Drawing Source Code
/* C# Code - TChart Drawing */
private static string _ConnectionStr1 = @"Data Source=localhost\SQLEXPRESS;Initial Catalog=tempdb;Integrated Security=True;Pooling=False";
private static SqlConnection _con;
private static SqlCommand _cmd;
private Steema.TeeChart.TChart _tChart;
private SqlDataReader SqlReader(string strqury)
{
_con = new SqlConnection(_ConnectionStr1); ;
_cmd = new SqlCommand();
_cmd.Connection = _con;
SqlDataReader reader = null;
try
{
_cmd.Parameters.Clear();
_cmd.CommandText = strqury;
reader = _cmd.ExecuteReader();
return reader;
}
catch (Exception e)
{
new MassException(e.Message);
return reader;
}
}
private void ChartDraw()
{
Initialize();
SqlDataReader reader = SqlReader("select TKINTIME,VALUE FROM TChartTable");
if(reader != null && reader.HasRows)
{
GetPoint();
_tChart.Series[_tChart.Series.Count - 1].Title = strlegnd;
_tChart.Series[_tChart.Series.Count - 1].Marks.Text = strqury;
_tChart.Series[_tChart.Series.Count - 1].XValues.DataMember = "TKINTIME";
_tChart.Series[_tChart.Series.Count - 1].YValues.DataMember = "VALUE";
_tChart[_tChart.Series.Count - 1].XValues.DateTime = true;
_tChart.Series[_tChart.Series.Count - 1].DataSource = reader;
}
Form frm = new Form();
tChart.Dock = DockStyle.Fill;
frm.Controls.Add(tChart);
frm.Size = new Size(500, 300);
frm.Show();
}
public void Initialize()
{
_tChart = new Steema.TeeChart.TChart();
_tChart.Axes.Bottom.Labels.Angle = 90;
_tChart.Axes.Bottom.MaximumOffset = 10;
_tChart.Axes.Bottom.MinimumOffset = 10;
_tChart.Axes.Left.MaximumOffset = 10;
_tChart.Axes.Left.MinimumOffset = 10;
_tChart.Aspect.Chart3DPercent = 0;
_tChart.Aspect.Orthogonal = false;
_tChart.Aspect.View3D = false;
_tChart.Axes.Bottom.Grid.Visible = false;
_tChart.Axes.Bottom.Labels.Font.Name = "Tahoma";
_tChart.Axes.Bottom.Labels.Font.Size = _defaultfontsize;
_tChart.Axes.Bottom.Labels.Font.SizeFloat = _defaultfontsize;
_tChart.Axes.Bottom.Title.Font.Name = "Arial";
_tChart.Axes.Left.Grid.Style = System.Drawing.Drawing2D.DashStyle.DashDotDot;
_tChart.Axes.Left.Labels.Font.Name = "Tahoma";
_tChart.Axes.Left.Labels.Font.Size = _defaultfontsize;
_tChart.Axes.Left.Labels.Font.SizeFloat = _defaultfontsize;
_tChart.Axes.Left.Title.Font.Name = "Arial";
_tChart.Axes.Right.Labels.Font.Name = "Tahoma";
_tChart.Axes.Right.Labels.Font.Size = _defaultfontsize;
_tChart.Axes.Right.Labels.Font.SizeFloat = _defaultfontsize;
_tChart.BackColor = System.Drawing.Color.White;
_tChart.Cursor = System.Windows.Forms.Cursors.Default;
_tChart.Header.Font.Bold = true;
_tChart.Header.Font.Brush.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
_tChart.Header.Font.Name = "Arial";
_tChart.Header.Lines = new string[] {
""};
_tChart.Header.Shadow.Height = 1;
_tChart.Header.Shadow.Width = 1;
_tChart.Legend.Font.Size = _defaultfontsize;
_tChart.Legend.Font.SizeFloat = _defaultfontsize;
_tChart.Legend.Pen.Color = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
_tChart.Legend.Shadow.Visible = false;
_tChart.Legend.Title.Font.Bold = false;
_tChart.Legend.Title.Font.Name = "Arial";
_tChart.Legend.Title.Font.Size = _defaultfontsize;
_tChart.Legend.Title.Font.SizeFloat = _defaultfontsize;
_tChart.Legend.Title.Pen.Visible = false;
_tChart.Location = new System.Drawing.Point(0, 0);
_tChart.Margin = new System.Windows.Forms.Padding(0);
_tChart.Name = "tChart";
_tChart.Panel.Brush.Color = System.Drawing.Color.White;
_tChart.Panel.Brush.Gradient.Visible = false;
_tChart.Panel.MarginBottom = 1;
_tChart.Panel.MarginLeft = 1;
_tChart.Panel.MarginRight = 1;
_tChart.Panel.MarginTop = 1;
_tChart.Size = new System.Drawing.Size(466, 264);
_tChart.SubHeader.Font.Name = "Arial";
_tChart.SubHeader.Visible = true;
_tChart.TabIndex = _index;
_tChart.Walls.Back.Brush.Color = System.Drawing.Color.White;
_tChart.Walls.Back.Brush.Gradient.Visible = false;
_tChart.Walls.Back.Pen.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
_tChart.ClickSeries += new Steema.TeeChart.TChart.SeriesEventHandler(tChart_ClickSeries);
_tChart.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None;
_tChart.Panel.Pen.Visible = true;
_tChart.Panel.Pen.Width = 1;
_tChart.Panel.Pen.Color = Color.Black;
_tChart.Zoom.Allow = false;
_tChart.Zoom.KeyShift = (Keys)Enum.Parse(typeof(Keys), "Shift");
_tChart.Axes.Bottom.Labels.DateTimeFormat = "MM-dd";
}
public void GetPoint()
{
Steema.TeeChart.Styles.Points pointSerie = new Steema.TeeChart.Styles.Points();
pointSerie.ClickPointer += new Steema.TeeChart.Styles.CustomPoint.ClickPointerEventHandler(Series_Clicked);
pointSerie.MouseEnter += new EventHandler(Series_MouseEnter);
pointSerie.MouseLeave += new EventHandler(Series_MouseLeave);
pointSerie.Pointer.Brush.Color = Color.Blue;
pointSerie.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
pointSerie.Pointer.Visible = true;
pointSerie.Pointer.VertSize = _statusSeriessize; ;
pointSerie.Pointer.HorizSize = _statusSeriessize; ;
_tChart.Series.Add(pointSerie);
}
I think that this code's performance ( Chart Drawing Speed ) is very good
but X-value output error is only one remaining problem for appling to our
system.