Deleting points that are not on the screen

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
andyb
Newbie
Newbie
Posts: 8
Joined: Tue Feb 01, 2005 5:00 am

Deleting points that are not on the screen

Post by andyb » Tue Mar 28, 2006 9:18 am

Hi,

I'm trying to delete points as they are removed from the screen. The problem is, I don't know how I can find the location of the earliest point.

From the example...
tChart1[0].YValues.Value[0] =103.96; MessageBox.Show(tChart1[0].YValues.First.ToString());

I can delete point 0, but after that, is that location ever used again? Is there a way that I can use a "get_FirstPoint" style function, or another way to do it that you could recommend.

I never know how many points I will need to remove each time, as every second, between 0 and 3 points are added, so I'd like to be able to use some code like: -

Code: Select all

minimum = x value of last point being displayed
while (first point < minimum)
   delete first point
That code will be called every second.

Is there a way to do that, or a better way that anyone knows.

Cheers

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 Mar 28, 2006 9:35 am

Hi andyb,

Yes, you can use something like the code below. This method uses the series Delete method which has several overrides. In that case it always removes the first point in the series.

Code: Select all

    private int count = 0;
    private int MaxDisplayedPoints = 100;

    private void timer1_Tick(object sender, EventArgs e)
    {
      Random randY=new Random();

      for (int i = 0; i < 3; ++i)
      {
        count++;
        line1.Add(count,randY.Next());
      }

      while (line1.XValues[j] < count - MaxDisplayedPoints) line1.Delete(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

andyb
Newbie
Newbie
Posts: 8
Joined: Tue Feb 01, 2005 5:00 am

Post by andyb » Tue Mar 28, 2006 10:10 am

Thanks Narcis,

That sounds like what I need. Where are you getting j from?

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 Mar 28, 2006 10:23 am

Hi andyb,

Sorry, my fault. I originally used a variable called j but then I noticed it wasn't necessary so the code would be:

Code: Select all

    private int count = 0;
    private int MaxDisplayedPoints = 100;

    private void timer1_Tick(object sender, EventArgs e)
    {
      Random randY=new Random();

      for (int i = 0; i < 3; ++i)
      {
        count++;
        line1.Add(count,randY.Next());
      }

      while (line1.XValues[0] < count - MaxDisplayedPoints) line1.Delete(0);
    }
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