Does anyone know if there is a way to find the y coordinate for a given x coordinate for an XY series when there isn't a matching x coordinate in the series?
eg If a series contains points (2, 10), (4, 30), (9, 42.56), (10.2, 24.1)...
... is there a way to get the y coordinate when x=7 without having to perform my own interpolation?
I know that it seems as if I'm being lazy, but there is a performance issue when I calculate it myself and I am hoping there is a more efficient built-in method to interpolate (and/or extrapolate).
Thanks in advance,
Richard
Interpolation/extrapolation using ActiveX TeeChart component
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Richard,
You can do it using a vertical cursor tool and implementing it's OnChange event:
You can do it using a vertical cursor tool and implementing it's OnChange event:
Code: Select all
Private Sub Form_Load()
TChart1.Series(0).FillSampleValues 10
TChart1.Tools.Items(0).asTeeCursor.Style = cssVertical
End Sub
Private Sub TChart1_OnCursorToolChange(ByVal Tool As Long, ByVal X As Long, ByVal Y As Long, ByVal XVal As Double, ByVal YVal As Double, ByVal Series As Long, ByVal ValueIndex As Long)
Dim ValuesStr As String
ValuesStr = "X: " + CStr(TChart1.Tools.Items(0).asTeeCursor.XVal) _
+ ", Y: " + CStr(TChart1.Tools.Items(0).asTeeCursor.YVal)
TChart1.Header.Text.Clear
TChart1.Header.Text.Add (ValuesStr)
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 |
Instructions - How to post in this forum |
Hi Narcis,
I tried your code and found that moving the vertical cursor only changes the x axis value - the y axis value never changes. (I also notice that if both horizontal and vertical are enabled, changing the y value doesn't report the correspondig x value either.)
In my program I want to programmatically iterate through each x value in one series and find what the corresponding y value on another series is for the same x value.
I tried your code and found that moving the vertical cursor only changes the x axis value - the y axis value never changes. (I also notice that if both horizontal and vertical are enabled, changing the y value doesn't report the correspondig x value either.)
In my program I want to programmatically iterate through each x value in one series and find what the corresponding y value on another series is for the same x value.
Re: Interpolation/extrapolation using ActiveX TeeChart compo
I think not. You'll have to calculate local linear approximate and then use it for calculating y=y(x). It's not that complication + it really doesn't take heavy tool on cpu <gg>. I did an example for Delphi, but the same approach can be used for AX or .NET version. A discusion can be found6919168 wrote:... is there a way to get the y coordinate when x=7 without having to perform my own interpolation?
here.
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Hi.
Ok, the number of points can slow down the search for closest points. But there is no need to search all points - you can do a left/right search once you have initial reference point (since x values are already sorted).have sporradic data going back to 1976
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Just thinking....My data source is via ADO and I can run a quick query to find the 1st date in my second curve (ie the one I want to get the y value from) which comes after the seek date, and then use a vertical cursor attached to the 2nd curve to get the index and y2 value, and hence the date at the previous index and the y1 value - Problem solved !
Thanks again
Ritchie
Thanks again
Ritchie