TCursorTool calculation

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

TCursorTool calculation

Post by Banjovi » Mon Mar 16, 2015 8:07 pm

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
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TCursorTool calculation

Post by Yeray » Tue Mar 17, 2015 3:11 pm

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,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

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

Re: TCursorTool calculation

Post by Banjovi » Tue Mar 17, 2015 3:24 pm

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

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

Re: TCursorTool calculation

Post by Yeray » Tue Mar 17, 2015 3:27 pm

Hello,

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

Post Reply