Page 1 of 1

Fastline.Add - load with individual points or pass array

Posted: Fri Feb 15, 2019 12:01 am
by 15685169
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

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

Posted: Fri Feb 15, 2019 10:01 am
by Christopher
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?

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

Posted: Sun Feb 24, 2019 9:21 am
by 15685169
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

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

Posted: Mon Feb 25, 2019 7:13 am
by Christopher
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 18210 times
explorer_2019-02-25_08-08-54.png
explorer_2019-02-25_08-08-54.png (10.57 KiB) Viewed 18210 times
could you please generate a new zip file for me and post it here again?

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

Posted: Mon Feb 25, 2019 1:03 pm
by 15685169
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

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

Posted: Mon Feb 25, 2019 1:06 pm
by 15685169
Here is the file Zip compressed as well. :-)

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

Posted: Mon Feb 25, 2019 6:13 pm
by Christopher
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());
		}

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

Posted: Mon Feb 25, 2019 9:36 pm
by 15685169
Hi Christopher,

Brilliant! :D

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

Kind regards
Rob