difference between interpolated values

TeeChart for ActiveX, COM and ASP
Post Reply
Aligator
Newbie
Newbie
Posts: 7
Joined: Mon Apr 04, 2005 4:00 am
Location: France
Contact:

difference between interpolated values

Post by Aligator » Fri Mar 09, 2007 6:41 am

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

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Fri Mar 09, 2007 10:25 am

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
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Aligator
Newbie
Newbie
Posts: 7
Joined: Mon Apr 04, 2005 4:00 am
Location: France
Contact:

Post by Aligator » Fri Mar 09, 2007 10:56 am

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

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 Mar 09, 2007 11:06 am

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

Aligator
Newbie
Newbie
Posts: 7
Joined: Mon Apr 04, 2005 4:00 am
Location: France
Contact:

Post by Aligator » Fri Mar 09, 2007 1:32 pm

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

Post Reply