skip nulls problem

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Alexbb
Newbie
Newbie
Posts: 15
Joined: Mon Jul 09, 2007 12:00 am

skip nulls problem

Post by Alexbb » Tue Jun 17, 2008 1:18 pm

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

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 17, 2008 1:52 pm

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.
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

Alexbb
Newbie
Newbie
Posts: 15
Joined: Mon Jul 09, 2007 12:00 am

skip nulls

Post by Alexbb » Tue Jun 17, 2008 6:24 pm

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?

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

Post by Narcís » Wed Jun 18, 2008 10:30 am

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.
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

Alexbb
Newbie
Newbie
Posts: 15
Joined: Mon Jul 09, 2007 12:00 am

question

Post by Alexbb » Wed Jun 18, 2008 1:22 pm

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

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

Post by Narcís » Wed Jun 18, 2008 2:32 pm

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];
		}
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

Post Reply