How to determine the data visible in the chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
jamsoft
Newbie
Newbie
Posts: 11
Joined: Thu May 29, 2008 12:00 am

How to determine the data visible in the chart

Post by jamsoft » Thu Dec 11, 2008 1:22 pm

Hello,
i've already searched the forums but could not find a hint on this, so here's my question:

I'm adding several Steema.TeeChart.Styles.Line Series to the TChart control via the method public int Add(DateTime x, double y);

The user can freely pan and zoom in the tchart control that displays the data.
I'd like to know the earliest and latest visible dataset. So i can add
a header to the chart like "Data from yymmdd to yymmdd"
this is important for printing the chart, since sometimes the chart only displays the time of the datasets without the date

How can i achieve this?
It would be okay for me if i scan through the data in Series and can
somehow determine whether the dataset is visible.

Regards
Klaus

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 Dec 11, 2008 1:59 pm

Hi Klaus,

You can try doing something like this:

Code: Select all

      double first = tChart1[0].XValues[tChart1[0].FirstVisibleIndex];
      double last = tChart1[0].XValues[tChart1[0].LastVisibleIndex];
Or this:

Code: Select all

      double first = tChart1[0].XValues[tChart1[0].FirstDisplayedIndex()];
      double last = tChart1[0].XValues[tChart1[0].LastDisplayedIndex()];
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

jamsoft
Newbie
Newbie
Posts: 11
Joined: Thu May 29, 2008 12:00 am

Post by jamsoft » Thu Dec 11, 2008 2:28 pm

Hello Narcís,
thanks this is exactly what i needed, i use:

Code: Select all

 
            Series series = tChart1.Series[0];
            int firstVisibleIndex = series.FirstVisibleIndex;
            int lastVisibleIndex = series.LastVisibleIndex;

            earliest = Steema.TeeChart.Utils.DateTime(series.XValues[firstVisibleIndex]);
            latest = Steema.TeeChart.Utils.DateTime(series.XValues[lastVisibleIndex]);
to also back-convert to DateTime format
Kind regards, have a nice evening
Klaus

Post Reply