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
difference between interpolated values
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:
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
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
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
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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.
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 |
Instructions - How to post in this forum |