GetFirstValueIndex method returns wrong index

TeeChart for ActiveX, COM and ASP
Post Reply
Alex
Newbie
Newbie
Posts: 9
Joined: Wed Mar 01, 2006 12:00 am

GetFirstValueIndex method returns wrong index

Post by Alex » Thu Aug 30, 2012 12:01 pm

Hi all,
I use GetFirstValueIndex method at my code but it seems to return wrong indexes.
Documentation says:
This function / property returns the ValueIndex of the First point in the Series that has an X value which is between the Horizontal Axis Maximum and Minimum values.
When no Zoom is applied to the Chart, and the Axis are Automatic, the FirstValueIndex is 0. If the Series has no points or there are no visible points, the FirstValueIndex returns -1.

Code: Select all

double nMinXValue = m_oTChart.GetAxis().GetBottom().GetMinimum();
double nMaxXValue = m_oTChart.GetAxis().GetBottom().GetMaximum();

long nMinXIndex = m_oTChart.Series(0).GetFirstValueIndex();
long nMaxXIndex = m_oTChart.Series(0).GetLastValueIndex();			

double nAux = m_oTChart.Series(0).GetXValues().GetValue(nMinXIndex);
I try this code with only one serie with wrong results: nMinXValue is 102.87, nMaxXValue is 344, nMaxXIndex is also 344 but nAux is 99, that is not between axis maximum and minimum values.

Any idea?

Thanks and best regards,
Alex

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: GetFirstValueIndex method returns wrong index

Post by Yeray » Thu Aug 30, 2012 3:17 pm

Hi Alex,

I've tried to reproduce your situation with the following simple example but it seems to give me the expected results both at startup, when zooming, unzooming and scrolling.

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False

  TChart1.AddSeries scPoint
  TChart1.Series(0).Marks.Visible = True
  TChart1.Series(0).Marks.Style = smsPointIndex

  Dim i As Integer
  For i = 1 To 10
    TChart1.Series(0).AddXY i * 100, i, "", clTeeColor
  Next i

  ShowMinMax
End Sub

Private Sub ShowMinMax()
  Dim nMinXIndex, nMaxXIndex As Integer
  Dim nMinXValue, nMaxXValue, nAux As Double
  
  TChart1.Environment.InternalRepaint
  
  nMinXValue = TChart1.Axis.Bottom.Minimum
  nMaxXValue = TChart1.Axis.Bottom.Maximum
  nMinXIndex = TChart1.Series(0).FirstValueIndex
  nMaxXIndex = TChart1.Series(0).LastValueIndex
  nAux = TChart1.Series(0).XValues.Value(nMinXIndex)

  Caption = "nMinXValue: " + Format$(nMinXValue, "#,###")
  Caption = Caption + ", nMaxXValue: " + Format$(nMaxXValue, "#,###")
  Caption = Caption + ", nMinXIndex: " + Str$(nMinXIndex)
  Caption = Caption + ", nMaxXIndex: " + Str$(nMaxXIndex)
  Caption = Caption + ", nAux: " + Format$(nAux, "#,###")
End Sub

Private Sub TChart1_OnScroll()
  ShowMinMax
End Sub

Private Sub TChart1_OnUndoZoom()
  ShowMinMax
End Sub

Private Sub TChart1_OnZoom()
  ShowMinMax
End Sub
Maybe you are doing something different or you are using a different version. Please, give it a try to the latest version is possible.
If you still have problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.
Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Alex
Newbie
Newbie
Posts: 9
Joined: Wed Mar 01, 2006 12:00 am

Re: GetFirstValueIndex method returns wrong index

Post by Alex » Fri Aug 31, 2012 6:32 am

Hi,
I have several series scFastLine, without marks and I have legend enabled. The rest is the same as your code. I am using TeeChart Pro ActiveX version 7.0.
I will make some research on this and will try latest version and feedback you as soon as posible.

Thanks,
Alex

Post Reply