Page 1 of 1
skip nulls problem
Posted: Tue Jun 17, 2008 1:18 pm
by 13046028
Hello,
I wrote a program that reads data from datatable and presents it on tchart. I have nulls in my data table. The problem is when the first value in the datatable is null. I get in correct graph where the first line drops (goes down) . For example if I have next values (o, null), (1, 1) ,(2,null)
my graph will start from (0,null) and the y valu of this pont drops ldown (I use skipnulls option and Vs 2005). I have a line down. I need that my graph will start from (1,1). How can I fix it?
Alex
Posted: Tue Jun 17, 2008 1:52 pm
by narcis
Hi Alex,
Have you looked at TreatNulls and DefaultNullValue properties? You'll find an example at What's New?\Welcome !\New in Series\FastLine Null points in the features demo, available at TeeChart's program group.
skip nulls
Posted: Tue Jun 17, 2008 6:24 pm
by 13046028
Hi,
I used this option for null defutl value. But I want that if my first value in datatable is null (y axsis) , The chart will start from the next value that is not null. And not from degulat value as i set.
dt = new DataTable();
DataColumn col1 = new DataColumn("x", Type.GetType("System.Object"));
dt.Columns.Add(col1);
col1 = new DataColumn("y", Type.GetType("System.String"));
dt.Columns.Add(col1);
int length = 10;
for (int i = 0; i < length; i++)
{
DataRow dr = dt.NewRow();
dr[0] = i;
dr[1] = 1 ;
dt.Rows.Add(dr);
}
dt.Rows[0][1] = DBNull.Value;
dt.Rows[1][1] = DBNull.Value;
dt.Rows[5][1] = DBNull.Value;
dataGridView1.DataSource = dt;
Steema.TeeChart.Styles.FastLine fl = new Steema.TeeChart.Styles.FastLine();
// fl.DefaultNullValue = 1;
fl.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.Skip;
tChart1.Series.Add(fl);
fl.XValues.DataMember = dt.Columns[0].Caption;
fl.YValues.DataMember = dt.Columns[1].Caption;
fl.DataSource = dt;
If you will run this code and drug the chart down you will see the problem.
How cani solve it?
Posted: Wed Jun 18, 2008 10:30 am
by narcis
Hi Alex,
Thanks for the code. It seems to be working fine here using latest TeeChart for .NET v3 maintenance release available at the client area. Which TeeChart version are you using?
Thanks in advance.
question
Posted: Wed Jun 18, 2008 1:22 pm
by 13046028
I am using version3 for vs 2005
Can you write me a pice of code that has the next data in datattable points: (0,null) (1,null) (2,2) (3,3) (4,4)
and the chart will start from (2,2) and will skipp the nulls
This is the main problem, without usin null defult value.
Thanks
Posted: Wed Jun 18, 2008 2:32 pm
by narcis
Hi Alex,
Modifying your code like shown below works fine for me here:
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataColumn col1 = new DataColumn("x", Type.GetType("System.Object"));
dt.Columns.Add(col1);
col1 = new DataColumn("y", Type.GetType("System.String"));
dt.Columns.Add(col1);
int length = 10;
for (int i = 0; i < length; i++)
{
DataRow dr = dt.NewRow();
dr[0] = i;
dr[1] = 1;
dt.Rows.Add(dr);
}
dt.Rows[0][1] = DBNull.Value;
dt.Rows[1][1] = DBNull.Value;
dt.Rows[5][1] = DBNull.Value;
//dataGridView1.DataSource = dt;
Steema.TeeChart.Styles.FastLine fl = new Steema.TeeChart.Styles.FastLine();
// fl.DefaultNullValue = 1;
fl.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.Ignore;
tChart1.Series.Add(fl);
fl.XValues.DataMember = dt.Columns[0].Caption;
fl.YValues.DataMember = dt.Columns[1].Caption;
fl.DataSource = dt;
int j = 0;
while ((fl.YValues[j] == 0.0) && (j < fl.Count))
{
j++;
}
tChart1.Axes.Bottom.AutomaticMinimum = false;
tChart1.Axes.Bottom.Minimum = fl.XValues[j];
}