Page 1 of 1

difference between interpolated values

Posted: Fri Mar 09, 2007 6:41 am
by 9526547
Hi,
I have a chart with two series, X bootom is date time, Y is numeric. I must display the caculated difference betwwen the 2 series when I move the cursor accross one of the serie. Is this possible to get this calculated value between two points ? how ? ... thanks
JP

Posted: Fri Mar 09, 2007 10:25 am
by 9348258
Hi Aligator

You have to calculate the difference in the "OnMouseMove" event. You have got two ways to calculate the difference:

1- You can use the Subtract Function, and hide the line but catch the points.
2- You can calculate the difference between two series, doing the subtract with the two Y values, as below code:

Code: Select all

Private Sub Form_Load()
    TChart1.Series(0).FillSampleValues 10
    TChart1.Series(1).FillSampleValues 10
    
    'TChart1.Series(2).Active = False ' If you use a Subtract Function
End Sub

Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    For i = 0 To TChart1.SeriesCount - 2
        Index = TChart1.Series(i).Clicked(X, Y)
        
        If Index <> -1 Then
            TChart1.Header.Text.Clear
            'TChart1.Header.Text.Add CStr(TChart1.Series(2).YValues.Value(Index)) 'If you use a Subtract Function
            TChart1.Header.Text.Add CStr(TChart1.Series(1).YValues.Value(Index) - _
                                        TChart1.Series(0).YValues.Value(Index))
        End If
    Next
End Sub

Posted: Fri Mar 09, 2007 10:56 am
by 9526547
Thanks, this is not bad but the result is false if the pointer is between two points, the nearest point before is taken for the calculation.
Do you think there is a possibility to get the real values on each charts to do the same calculation ?
I must handle two records with different intervals on the same X date time. So, if we can get the displayed value for each record, it will be great and easy to do.
regards
JP

Posted: Fri Mar 09, 2007 11:06 am
by narcis
Hi JP,

In that case you should interpolate series points as shown on this thread. Once you have retrieved series values you just need to make the difference as Edu showed you.

Posted: Fri Mar 09, 2007 1:32 pm
by 9526547
Hi, this is fantastic !!!
it's exactly what I need.
Thanks for your help.
Next time I will try to search a little more into the Forum before I ask something.

JP