Determine Y-values in a colorgrid series

TeeChart for ActiveX, COM and ASP
Post Reply
Rover
Newbie
Newbie
Posts: 12
Joined: Thu Jun 22, 2006 12:00 am

Determine Y-values in a colorgrid series

Post by Rover » Thu Jun 29, 2006 1:21 pm

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 :cry: .

Kind regards,

Jan

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 Jun 29, 2006 1:30 pm

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
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

Rover
Newbie
Newbie
Posts: 12
Joined: Thu Jun 22, 2006 12:00 am

Clicked does the trick, only one additional problem

Post by Rover » Thu Jun 29, 2006 1:52 pm

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

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 Jun 29, 2006 2:09 pm

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
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

Rover
Newbie
Newbie
Posts: 12
Joined: Thu Jun 22, 2006 12:00 am

Some more details

Post by Rover » Thu Jun 29, 2006 2:47 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Jun 30, 2006 7:58 am

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
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