## TCursorTool calculation

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Banjovi
Newbie
Posts: 11
Joined: Thu Sep 22, 2005 4:00 am

### TCursorTool calculation

Using TeeChart Pro 7.07 with BCB6

I'm trying to calculate the Y value of a TLineSeries on a cursor event. To complicate matters, I have multiple charts on the form and multiple series on each chart. What I want to do is report the y value for each series that a vertical cursor intersects. Each series has its own custom vertical axis. All series share the same x-axis but have varying numbers of points. I've tried several methods used in examples from the forum, but can't seem to get the right thing.

How can I calculate the correct Y value for each series?

Code: Select all

``````void __fastcall TfrmChartDisp::CursorChange(TCursorTool *Sender, Integer x, Integer y, Double XValue, Double YValue, TChartSeries *Series,
Integer ValueIndex)
{
String s;

if( Sender )
{
// Which chart?
chrt = (TChart *) Sender->ParentChart;

for (int i = 0; i < chrt->SeriesCount(); i++)
{
int xpos = chrt->Axes->Bottom->CalcXPosValue(XValue);
int ypos = chrt->Series[i]->CalcYPos(ValueIndex);

double d = 100.0;
int YValIndex = Sender->NearestPoint(cssVertical, d);

s = String( XValue ) + String(", ") + String( YValue );

// Add label next to cursor at ypos
chrt->Canvas->TextOut( xpos, ypos, s);
}
}
}
``````

Yeray
Site Admin
Posts: 8912
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

### Re: TCursorTool calculation

Hello,

Have you seen the Interpolation example?
Take a look at the demo at All features\Welcome!\Chart Styles\Standard\Line (Strip)\Interpolating Line series
Best Regards,
 Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) Please read our Bug Fixing Policy

Banjovi
Newbie
Posts: 11
Joined: Thu Sep 22, 2005 4:00 am

### Re: TCursorTool calculation

Thank you for the suggestion, however that item is not included in the v7.07 demo. Is it available online somewhere?

Yeray
Site Admin
Posts: 8912
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

### Re: TCursorTool calculation

Hello,

Yes, here.
Best Regards,
 Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) Please read our Bug Fixing Policy