Click Chart to get Series Value

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
MattG
Newbie
Newbie
Posts: 2
Joined: Wed Jul 21, 2004 4:00 am

Click Chart to get Series Value

Post by MattG » Wed Oct 13, 2004 8:07 pm

Let's say I have a chart and a TFastLineSeries.

I click on a coordinate on the *chart*, and I get an X and a Y value (MouseDown or MouseUp, whichever).
Nothing I've seen anywhere (searched for 'click' etc) seems to be able to tell me how I can associate the X coordinate of the mouse (whether it's been converted to the corresponding Axis value or not) with a ValueIndex so that I can do this:

ValueIndex: Integer;
Yvalue: Double;

...
ValueIndex := Series1.SomeFunctionHere(X);
Yvalue := Series1.YValues[ValueIndex];

I do not want to have to click on Series1, since it's thin. Yes, I could go searching around X,Y for a Series1.Clicked(X+dx,Y+dy) but this seems like it's unnecessary.

I'm using TeeChart7 for Delphi 7 if that makes a difference.

Maybe I'm missing something. But I'm quite frustrated now.

Can anyone fill in the missing blanks?

Thanks to all.

Regards,

Matt

Pep
Site Admin
Site Admin
Posts: 3298
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Oct 14, 2004 3:37 pm

Hi Matt,

you can use the CalcXPosValue and CalcYPosValue methods :
showmessage( inttostr(Chart1.Axes.Left.CalcYPosValue(Y)));
showmessage( inttostr(Chart1.Axes.Left.CalcXPosValue(X)));
Also, I've posted one example which could be usefull for you into the steema.public.attachments newsgroup ( at news://berneda.com ). It shows how to get the XYValues of the Series using a line like a cursor.

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Fri Oct 15, 2004 1:12 pm

Could you use a Cursor Tool ? Its Snap property determine whether they are locked to the data points or not. If Snap is True, you have to use two Cursor Tools, One for Vert, one for Horiz.

Pep
Site Admin
Site Admin
Posts: 3298
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Oct 15, 2004 1:59 pm

Hi Steve,

yes, you should be able to do the same using the Cursor tool.

Post Reply