Page 1 of 1

How to determine the data visible in the chart

Posted: Thu Dec 11, 2008 1:22 pm
by 13049141
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

Posted: Thu Dec 11, 2008 1:59 pm
by narcis
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()];

Posted: Thu Dec 11, 2008 2:28 pm
by 13049141
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