How do I the Y-value of a Series when I know the X value?

TeeChart for ActiveX, COM and ASP
Post Reply
Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

How do I the Y-value of a Series when I know the X value?

Post by Dave » Tue Feb 17, 2009 4:32 pm

Ive a chart that displays a line.

Im using a vertical cursor (set up so it follows the mouse). I can read the x-coord by doing;

double x = mainCursor.XValue;

If I read the y-value by doing

double x = mainCursor.XValue;

then Im just getting the mouse y-coord. I want the y-coord of the line. Is there an easy way to do this. Im assuming there is a function that I can call by passing the x-coord.

One way Ive thought of doing it is this;

int X;
double Y = theChart.Series[0].YValues[X];

The problem is I know the x-coord But I dont know the x index value.

Is there a simple solution here? Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Feb 17, 2009 4:56 pm

Hi Dave,

I can think of 2 options here:

1. Setting CursorTool to Snap=True, for example:

Code: Select all

    TChart1.Tools.Items(0).asTeeCursor.Snap = True
2. Use the interpolation example I posted here:

http://www.teechart.net/support/viewtopic.php?t=4161
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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Feb 18, 2009 9:01 am

Hi Dave,

Reading this thread I assume you are using TeeChart for .NET because of the syntax used. In which case you can find the interpolating example at All Features\Welcome !\Chart styles\Standard\Line(Strip)\Interpolating line series in the features demo available at TeeChart's program group.
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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Wed Feb 18, 2009 9:02 am

Narcis

Thanks. Im using;

mainCursor.SnapToPoint();

where

mainCursor = new Steema.TeeChart.Tools.CursorTool(theChart.Chart);


However Ive probably not described the question very well. I have a chart that displays a line (something like a share price graph) and I have added the vertical cursor. So when I drag the mouse left or right I control the vertical cursor line. What Im trying to get is the Yvalue of the point where the vertical cursor line intersects the share price graph line.

Im not interested in intermediate values (between points) so Ive set the snaptopoint() function.

Ive tried to do it (as described in the initial post) but Im guessing Im making it more complicated that it really is. I suspect there could be a single function call I could use?

Post Reply