Page 1 of 1
Determine Y-values in a colorgrid series
Posted: Thu Jun 29, 2006 1:21 pm
by 9531657
Hi,
I need to get the y-values (the intensity) of several color grid series within my chart. Given values are Mouse x-coordinate and fix Z index.
First I thought getxzvalues might by the right method, but that doesn't work

.
Kind regards,
Jan
Posted: Thu Jun 29, 2006 1:30 pm
by narcis
Hi Jan,
You can use something like this code:
Code: Select all
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim ValueIndex As Integer
For i = 0 To TChart1.SeriesCount - 1
ValueIndex = TChart1.Series(i).Clicked(X, Y)
If ValueIndex <> -1 Then
List1.AddItem CStr(TChart1.Series(i).YValues.Value(ValueIndex))
End If
Next
End Sub
Clicked does the trick, only one additional problem
Posted: Thu Jun 29, 2006 1:52 pm
by 9531657
My colorgrids have 64 lines (z-value). In order to use your code, I have to find out the y-coordinate of one of these lines (for the "clicked" method). Can you help there as well?
Thanks in advance,
Jan
Posted: Thu Jun 29, 2006 2:09 pm
by narcis
Hi Jan,
Once you retrieve the point where the mouse is (ValueIndex in my snippet) you can retrieve any value for this point, for example:
Code: Select all
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim ValueIndex As Integer
List1.Clear
For i = 0 To TChart1.SeriesCount - 1
ValueIndex = TChart1.Series(i).Clicked(X, Y)
If ValueIndex <> -1 Then
List1.AddItem "X: " & CStr(TChart1.Series(i).XValues.Value(ValueIndex))
List1.AddItem "Y: " & CStr(TChart1.Series(i).YValues.Value(ValueIndex))
List1.AddItem "Z: " & CStr(TChart1.Series(i).asColorGrid.ZValues.Value(ValueIndex))
End If
Next
End Sub
Some more details
Posted: Thu Jun 29, 2006 2:47 pm
by 9531657
Hi NarcĂs,
I should have told you, that these colorgrid series I ues are on different custom axis. The bottom axis represents the timeline, so no matter over which color grid the mouse is actually, I need to display the values of all colorgrids. The Y Value of the OnMouseMove Event is often outside of the series, so .clicked (x,y) would return -1.
Thanks for your fast answers.
Kind regards,
Jan
Posted: Fri Jun 30, 2006 7:58 am
by narcis
Hi Jan,
Ok, then try doing something like this:
Code: Select all
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim ValueIndex, XVal As Integer
Dim HorizAxis As TeeChart.IAxis
List1.Clear
For i = 0 To TChart1.SeriesCount - 1
Select Case TChart1.Series(i).HorizontalAxis
Case 0 'aTopAxis = 0
Set HorizAxis = TChart1.Axis.Top
Case 1, 2 'aBottomAxis = 1, aBothHorizAxis = 2
Set HorizAxis = TChart1.Axis.Bottom
Case 3 'aCustomHorizAxis = 3
Set HorizAxis = TChart1.Axis.Custom(TChart1.Series(i).HorizontalAxisCustom)
End Select
XVal = HorizAxis.CalcPosPoint(X)
ValueIndex = TChart1.Series(i).XValues.Locate(XVal)
If ValueIndex <> -1 Then
List1.AddItem "X: " & CStr(TChart1.Series(i).XValues.Value(ValueIndex))
List1.AddItem "Y: " & CStr(TChart1.Series(i).YValues.Value(ValueIndex))
List1.AddItem "Z: " & CStr(TChart1.Series(i).asColorGrid.ZValues.Value(ValueIndex))
End If
Next
End Sub