Series.Add (DataTable dt) problem...

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

Series.Add (DataTable dt) problem...

Post by glikoz » Mon Jun 27, 2005 12:36 pm

I try to make my own function library by deriving Function class..
I prefer overriding AddPoints Method to Calculate Method because of seperate Data And Graphics easily..
I prepared DataTable and tried to Add it to my function's Series by Add Method ...Here is the code:
(in the AddPoints Method)

base.Series.Add(myDataTable)

my DataTable has 2 columns: "X","Y" and 48 Rows
altough myDatatable was correctly set ,i couldnt see myfunction ...
Any opinion?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jun 28, 2005 11:20 am

Hi glikoz,

Would you be so kind to send us the code you are using so that we can reproduce your problem here? You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

I sent it to newsgroup

Post by glikoz » Tue Jun 28, 2005 12:33 pm


glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

Post by glikoz » Tue Jun 28, 2005 12:35 pm

I sent it to news://www.steema.net/steema.public.attachments ...
I sent demonstration code ..

glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

Here is the code

Post by glikoz » Wed Jun 29, 2005 11:11 am

/// Its my function class it derives from Function class
/// This Code Doesnt Work ! :
/// --------------------------------------------

public class MyFunction : Function
{

private DataTable mDataTable = new DataTable();

public DataTable DataTable

{

get { return mDataTable; }

}

public override void AddPoints(Array source)

{

if (!updating && source != null && source.Length > 0)

{

Series s = (Series)source.GetValue(0);

if (s.Count > 0)

{

base.Series.Clear();

DataTable dt = new DataTable();

dt.Columns.Add("X");

dt.Columns.Add("Y");

dt.Rows.Add( s.XValues[1],500);

dt.Rows.Add(s.XValues[2],100);

base.Series.Add(dt);



}

}

}

// Using Of MyFunction Class

Line l = new Steema.TeeChart.Styles.Line(tChart1.Chart);

MyFunction a = new MyFunction();

l.Function = a;

l.DataSource = tChart1.Series[0];

l.CheckDataSource();

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed Jun 29, 2005 1:16 pm

Hi ..

Try the following class:

Code: Select all

public class MyFunction : Function 
	{ 
		private DataTable mDataTable = new DataTable(); 

		public DataTable DataTable 
		{ 
			get { return mDataTable; } 
		} 

		public MyFunction() : this(null) {}

		public MyFunction(Chart c) : base(c) {}


		public override void AddPoints(Array source) 
		{ 
			if (!updating && source != null && source.Length > 0) 
			{ 
				Series s = (Series)source.GetValue(0); 
				if (s.Count > 0) 
				{
					Series.Clear();
					DataTable dt = new DataTable(); 
					dt.Columns.Add("X"); 
					dt.Columns.Add("Y"); 
					DataRow dr = dt.NewRow();
					dr["X"] = s.XValues[1];
					dr["Y"] = 500;
					dt.Rows.Add(dr);
					dr = dt.NewRow();
					dr["X"] = s.XValues[2];
					dr["Y"] = 100;
					dt.Rows.Add(dr);

					Series.XValues.DataMember = "X";
					Series.YValues.DataMember = "Y";
					Series.Add(dt); 
				} 
			}
		}   
	}
and consume it thus:

Code: Select all

private void Form1_Load(object sender, System.EventArgs e) 
		{ 
			commander1.Chart = tChart1;
			tChart1.Series[0].FillSampleValues();
			Line l = new Steema.TeeChart.Styles.Line(tChart1.Chart); 

			MyFunction a = new MyFunction(tChart1.Chart); 

			l.Function = a; 

			l.DataSource = tChart1.Series[0]; 

			l.CheckDataSource();
		} 
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

Thx..

Post by glikoz » Wed Jun 29, 2005 2:48 pm

Series.XValues.DataMember = "X";
Series.YValues.DataMember = "Y";


I missed this key point ... Thx for solution ...

Post Reply