Page 1 of 1
Series.Add (DataTable dt) problem...
Posted: Mon Jun 27, 2005 12:36 pm
by 8120345
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?
Posted: Tue Jun 28, 2005 11:20 am
by narcis
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.
I sent it to newsgroup
Posted: Tue Jun 28, 2005 12:33 pm
by 8120345
Posted: Tue Jun 28, 2005 12:35 pm
by 8120345
I sent it to news://
www.steema.net/steema.public.attachments ...
I sent demonstration code ..
Here is the code
Posted: Wed Jun 29, 2005 11:11 am
by 8120345
/// 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();
Posted: Wed Jun 29, 2005 1:16 pm
by Chris
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();
}
Thx..
Posted: Wed Jun 29, 2005 2:48 pm
by 8120345
Series.XValues.DataMember = "X";
Series.YValues.DataMember = "Y";
I missed this key point ... Thx for solution ...