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?
Series.Add (DataTable dt) problem...
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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.
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 |
Instructions - How to post in this forum |
I sent it to news://www.steema.net/steema.public.attachments ...
I sent demonstration code ..
I sent demonstration code ..
Here is the code
/// 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();
/// 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();
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi ..
Try the following class:
and consume it thus:
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);
}
}
}
}
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/
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/