Page 1 of 1

points in grid

Posted: Sun Apr 03, 2005 10:56 am
by 6925494
hello,
i'm french and i'm curently working on a project which included teechart
i just want to know how to get the Y pos of a point in the grid in order to send them by RS232 via my programation.
i also want to move in the grid tab to send all of the points one by one.
i'm working in C++ but if you have code in VB i will do the translation
thanks a lot
(sorry for my very bad english)

in french : bonjour a tous je travaille actuellement sur un projet incluant teechart je voudai savoir comment faire pour recuperer la valeur Y d'un point afin de l'envoyer par RS232 . Je veux egalement me deplacer dans ce tableau de point afin de pouvoir envoyer ceux ci l'un apres l'autre.
je travaille en language C++ mais si vous avez un bout de code en VB ca m'ira aussi
merci beaucoup

Posted: Mon Apr 04, 2005 7:18 am
by narcis
Hello loghan,

Please find bellow a couple of ways to get values from a series. In that case, in the Comand_Click() event all Y Values from a Series are retrieved, while in the OnMouseMove event X and Y Values we got X and Y values corresponding to the clicked series point.

Code: Select all

Private Sub Command1_Click()
    Dim ValuesStr As String
    
    For i = 0 To TChart1.Series(0).Count - 1
        ValuesStr = ValuesStr + " " + CStr(TChart1.Series(0).YValues.Value(i))
    Next i
    
    Label1.Caption = ValuesStr
End Sub

Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    Dim ValuesStr As String

    If TChart1.Series(0).Clicked(X, Y) <> -1 Then
        ValuesStr = "X: " + CStr(TChart1.Series(0).XValues.Value(TChart1.Series(0).Clicked(X, Y))) _
                + ", Y: " + CStr(TChart1.Series(0).YValues.Value(TChart1.Series(0).Clicked(X, Y)))
    
        TChart1.Header.Text.Clear
        TChart1.Header.Text.Add (ValuesStr)
    Else
        TChart1.Header.Text.Clear
        TChart1.Header.Text.Add ("")
    End If
End Sub

Posted: Sun Apr 10, 2005 11:32 am
by 6925494
thanks for your answer narcis .

I dont realy want to do that manually in fact i want to include the cose in a fonction who by a cercle do these tree things :

for ....................
first : take the Y value from the grid
second : move to the next value in the grid
third : send them to com (done)
next ...

have you a solution please in VB or in C++
thanks to all

Posted: Mon Apr 11, 2005 7:31 am
by narcis
Hi l0ghan,

Yes, that's what is done in my previous reply Command1_Click() procedure. I stored the info in a Label but you can do whatever you want with it. You could implement this in the Form_Load() event after populating series or wherever you prefer. You could do something like:

Code: Select all

Private Sub Form_Load()
    Dim YVal As Integer

    TChart1.Series(0).FillSampleValues 10
    
    For i = 0 To TChart1.Series(0).Count - 1
        YVal = TChart1.Series(0).YValues.Value(i)
        'Send YVal to COM port
    Next i
End Sub
You could also store all values in an array and send it to the COM port after the for loop.

Posted: Wed Apr 27, 2005 5:28 pm
by 6925494
thanks a lot