null points

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
ctusch
Newbie
Newbie
Posts: 34
Joined: Fri Aug 27, 2004 4:00 am

null points

Post by ctusch » Thu Mar 13, 2008 2:32 pm

Hello,

I'm using null points but they don't seem to work properly. I've set the TreatNull property of my FastLine to DoNotPaint. What I want it to do is that neither the point before nor the point after the null value connects to the null value point and also not to each other (ie. just a gap). But what I get is that either the point before or the one after the null point connects to it. Strangely sometimes it works.

I would be grateful for any hint!

EDIT:
Oh, I'm using version 3.2.2796.22187.

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

Post by Narcís » Thu Mar 13, 2008 3:11 pm

Hi ctusch,

What you request works fine for me here using the code below. Could you please check if it works fine at your end?

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			tChart1.Aspect.View3D = false;

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

			//line1.Pointer.Visible = true;
			line1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
			//line1.DefaultNullValue = 0;

			Random y = new Random();

			for (int i = 0; i < 25; i++)
			{
				if (i%5 ==0)
				{
					line1.Add();
				}
				else
				{
					line1.Add(y.Next());
				}
			}

		}
Also please note that there are newer releases at the client download area.
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

ctusch
Newbie
Newbie
Posts: 34
Joined: Fri Aug 27, 2004 4:00 am

Post by ctusch » Tue Apr 01, 2008 12:38 pm

Hello Narcis,

first off sorry for the late reply - I've been on vacation for the last 2 weeks. I've tried your code and of course it worked properly. So I've tried to reproduce my problem and I've succeeded. So when I have a Line line1 and I add the points in the following order:

Code: Select all

            double? nullValue = null;

            this.line1.Add(0, 0);
            this.line1.Add(1, 1);
            this.line1.Add(2, 1);
            this.line1.Add(3, 1);
            this.line1.Add(4, nullValue);
            this.line1.Add(5, 1);
            this.line1.Add(6, 1);
everything works fine. But if I for example add them in this order:

Code: Select all

            double? nullValue = null;

            this.line1.Add(0, 0);
            this.line1.Add(1, 1);
            this.line1.Add(2, 1);
            this.line1.Add(4, nullValue);
            this.line1.Add(5, 1);
            this.line1.Add(6, 1);
            this.line1.Add(3, 1);
the effect I described in my first post appears (null point gets connected with succeeding point) plus (I realized this just now) the point I added at the end isn't visible. The question now is is this expected behavior or is it a bug?
...
Okay while writing this I've done some more testing and I think I now know the source of the problem. The XValues are auto ordered ascending but it seems like the ordering doesn't affect the color collection. So when the last point is added it takes the index of the transparent point which makes it transparent instead of the supposed null point. So the new question is is there a way to change this behavior?

Thanks for any help!

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 Apr 01, 2008 1:10 pm

Hi ctusch,

No problem, hope you had a great vacation!

Thanks for the information. Now I can see which is the problem you are experiencing.

You can solve the ordering issue setting XValues.Order to None like in the code snippet below. Then, it is not that the null point is connected to the next one, what happens is that there's a line drawn from the maximum x value to the last added point. I've changed some properties so that you can see this clearer:

Code: Select all

			tChart1.Axes.Left.MaximumOffset = 10;			

			line1.Pointer.Visible = true;
			line1.ColorEach = true;
			line1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.None;

			double? nullValue = null;

			line1.Add(0, 0);
			line1.Add(1, 1);
			line1.Add(2, 1);
			//line1.Add(3, 1);
			line1.Add(4, nullValue);
			line1.Add(5, 1);
			line1.Add(6, 1);
			line1.Add(3, 1);
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

ctusch
Newbie
Newbie
Posts: 34
Joined: Fri Aug 27, 2004 4:00 am

Post by ctusch » Tue Apr 01, 2008 1:47 pm

Thanks for the prompt reply. Unfortunately this isn't what I'm looking for since I need the ascending order (I'm displaying measurement data). If there is no other solution I guess I have to change the TeeChart source code so that when I add a point it also changes the Colors collection.

Oh I just had another idea. I could always use the DateTime, double?, Color overload of the Add method and just pass Color.Empty as color. Do you think this would work well? Or would there be a performance hit?

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 Apr 01, 2008 2:01 pm

Hi ctusch,

I'm afraid this wouldn't work either. In fact, when setting a point to null, TeeChart internally sets its color to Color.Transparent. So that this code should work fine:

Code: Select all

			//tChart1.Aspect.View3D = false;
			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

			tChart1.Axes.Left.MaximumOffset = 10;			

			line1.Pointer.Visible = true;
			line1.ColorEach = true;
			//line1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.None;

			double? nullValue = null;

			line1.Add(0, 0);
			line1.Add(1, 1);
			line1.Add(2, 1);
			//line1.Add(3, 1);
			line1.Add(4, nullValue, Color.Transparent);
			line1.Add(5, 1);
			line1.Add(6, 1);
			line1.Add(3, 1);
However, it is not drawing a line between 2 and 3. This is a bug (TF02012933) that I've added to our defect list to be fixed for next releases.
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

ctusch
Newbie
Newbie
Posts: 34
Joined: Fri Aug 27, 2004 4:00 am

Post by ctusch » Tue Apr 01, 2008 2:28 pm

Hey,

yes I've also seen this bug. Anyways my idea actually works (though not with Color.Empty because TeeChart is ignoring empty colors, it just uses them internally to fill up the Colors array)!

Code: Select all

            line1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
            this.line1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;

            double? nullValue = null;

            line1.Add(0, 0, line1.Color);
            line1.Add(1, 1, line1.Color);
            line1.Add(2, 1, line1.Color);
            //line1.Add(3, 1);
            line1.Add(4, nullValue, Color.Transparent);
            line1.Add(5, 1, line1.Color);
            line1.Add(6, 1, line1.Color);
            line1.Add(3, 0.75, line1.Color);
Also you can leave out Color.Transparent when adding a null point.

EDIT: I just noticed that you should in fact leave out the Color.Transparent at all costs when adding null points because of the bug. It didn't matter in my little example because the null point was added at the end of the line and not inserted in the middle or at the beginning. The bug makes a 2nd entry for the succeeding index in the Colors collection, setting the next point to Color.Transparent (the actual point gets whatever color you specify).

Post Reply