Fastline.Add - load with individual points or pass array

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Innervations
Newbie
Newbie
Posts: 13
Joined: Wed Dec 19, 2018 12:00 am

Fastline.Add - load with individual points or pass array

Post by Innervations » Fri Feb 15, 2019 12:01 am

Hi,

We have been using TeeChart.NET for more than a decade and love it. We have always loaded data into the FastLine using code such as:

For count = 1 To samplecount
FastLineVelocity.Add(velocity(count), force(count))
Next count

However, we have been having trouble with a new plot and so have change to loading x and y data arrays and then passing the array to FastLine.Add e.g.

For count = 1 To samplecount - 1
xdata(count) = velocity(count)
ydata(count) = force(count)
Next count
FastLineForce.Add(xdata, ydata)

This is working so my question is should we continue with this method and is there some explanation as to why the first method results in FastLine that the data has the x and y coordinates out of order every 10 or so data points?

Thanks for any insight.
Best regards
Rob

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Fastline.Add - load with individual points or pass array

Post by Christopher » Fri Feb 15, 2019 10:01 am

Hello Rob,
wrote:
Fri Feb 15, 2019 12:01 am
We have been using TeeChart.NET for more than a decade and love it.
That's fantastic, we really are so pleased to hear that, thank you!
wrote:
Fri Feb 15, 2019 12:01 am
This is working so my question is should we continue with this method and is there some explanation as to why the first method results in FastLine that the data has the x and y coordinates out of order every 10 or so data points?
Clearly this shouldn't happen, and we will get to the bottom of the question soon. To help us do so, would you be so kind as to export the data you're having trouble with to a *.csv or *.xml file so we can reproduce your issue here?
Best Regards,
Christopher Ireland / 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

Innervations
Newbie
Newbie
Posts: 13
Joined: Wed Dec 19, 2018 12:00 am

Re: Fastline.Add - load with individual points or pass array

Post by Innervations » Sun Feb 24, 2019 9:21 am

Hi Christopher,

Thanks for your reply. I cannot figure out why there is a difference. With follow code:
For count = 0 To plotsamples
FastLineForce.Add(velocity(count + zoomstart), force(count + zoomstart))
Next count
I get the distorted graph attached. Some points are plotting correctly but then there is a sequence out and the back to correct etc.

However, if I use the following code with the exact same data arrays:
For count = 0 To plotsamples
xdata(count) = velocity(count + zoomstart)
ydata(count) = force(count + zoomstart)
Next count
FastLineForce.Add(xdata, ydata)

The graph is displayed correctly (image attached). I have attached the data as CSV but the Forum would not allow upload with .CSV extension so I have renamed FastLine Data.zip to get around the filetype filter.

Please let me know if you need anything else. I will be interested in your thoughts.

Best regards
Rob
Attachments
FastLine Data.zip
(9.42 KiB) Downloaded 737 times
FastLine Plot Correct.jpg
FastLine Plot Correct.jpg (68.97 KiB) Viewed 18164 times
FastLine Plot Distorted.jpg
FastLine Plot Distorted.jpg (122.2 KiB) Viewed 18164 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Fastline.Add - load with individual points or pass array

Post by Christopher » Mon Feb 25, 2019 7:13 am

Hello Rob,

I'm having problems trying to open the zip file here - both 7-Zip and Window's built-in zip extractor give me errors:
7zG_2019-02-25_08-08-43.png
7zG_2019-02-25_08-08-43.png (9.59 KiB) Viewed 18153 times
explorer_2019-02-25_08-08-54.png
explorer_2019-02-25_08-08-54.png (10.57 KiB) Viewed 18153 times
could you please generate a new zip file for me and post it here again?
Best Regards,
Christopher Ireland / 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

Innervations
Newbie
Newbie
Posts: 13
Joined: Wed Dec 19, 2018 12:00 am

Re: Fastline.Add - load with individual points or pass array

Post by Innervations » Mon Feb 25, 2019 1:03 pm

Hi Christopher,

The file is CSV so no need to unzip. Just rename changing .zip to .csv

I had to do this because the forum will not accept files with .csv extension.

Kind regards
Rob

Innervations
Newbie
Newbie
Posts: 13
Joined: Wed Dec 19, 2018 12:00 am

Re: Fastline.Add - load with individual points or pass array

Post by Innervations » Mon Feb 25, 2019 1:06 pm

Here is the file Zip compressed as well. :-)
Attachments
FastLine Data.zip
(3.53 KiB) Downloaded 749 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Fastline.Add - load with individual points or pass array

Post by Christopher » Mon Feb 25, 2019 6:13 pm

Hello Rob,

that'll teach me to read things more carefully! Thanks for your patience in sending me what I had mistakenly expected.

The answer is the ordering of the XValues - by default they are ordered, so when you add your values in one-by-one they are ordered. Adding in the values directly to the arrays bypasses this. The solution is to set the XValues ordering to None, e.g.

Code: Select all

		public struct MyStruct
		{
			public double Time { get; set; }
			public double Velocity { get; set; }
			public double Force { get; set; }
		}

		private void InitializeChart()
		{
			FastLine forvel = new FastLine(tChart1.Chart);

			var lines = File.ReadAllLines(@"C:\tmp\FastLine Data.csv").Skip(1)
			  .Select(x => x.Split(','))
				.Select(x => x.Select(y => double.Parse(y)))
				.Select(x => new MyStruct() { Time = x.ToArray()[0], Velocity = x.ToArray()[1], Force = x.ToArray()[2] }).ToArray();

			forvel.XValues.Order = ValueListOrder.None;

			for (int count = 0; count < lines.Length; count++)
			{
				forvel.Add(lines[count].Velocity, lines[count].Force);
			}

			//forvel.Add(lines.Select(x => x.Velocity).ToArray(), lines.Select(y => y.Force).ToArray());
		}
Best Regards,
Christopher Ireland / 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

Innervations
Newbie
Newbie
Posts: 13
Joined: Wed Dec 19, 2018 12:00 am

Re: Fastline.Add - load with individual points or pass array

Post by Innervations » Mon Feb 25, 2019 9:36 pm

Hi Christopher,

Brilliant! :D

All looking good now. Thanks very much. As always outstanding support from Steema!

Kind regards
Rob

Post Reply