Determining Series Name, and X and Y Values

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Determining Series Name, and X and Y Values

Post by McMClark » Sat Apr 08, 2006 2:59 pm

I am creating a Delphi 2005 VCL application. I want to add DBCharts at runtime. The user determines how many DBCharts will be created by choosing some paramters. What I need is the ability to know the series and X and y value when the user clicks on the DBChart. Can someone suggest some code?

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

Post by Narcís » Mon Apr 10, 2006 8:27 am

Hi McMClark,

You need to retrieve the values according to axes and screen coordinates. You can use something like this in DBChart's OnMouseMove event:

Code: Select all

procedure TForm1.DBChart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  i, index: Integer;
  XVal, YVal: double;
begin 

  for i:=0 to DBChart1.SeriesCount-1 do
  begin
    index:=DBChart1[i].Clicked(X,Y); 

    if (index <>-1) then
    begin
      XVal:=DBChart1[i].GetHorizAxis.CalcPosPoint(X);
      YVal:=DBChart1[i].GetVertAxis.CalcPosPoint(Y);
      Label1.Caption:=DBChart1[i].Name+': '+FloatToStr(XVal)+' - '+FloatToStr(YVal);
    end;
  end; 

end;
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

McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Post by McMClark » Fri Apr 14, 2006 1:44 pm

I am not sure if I asked for the correct thing. Will your code give the x and y axis value of the point clicked on the series?

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 Apr 18, 2006 9:46 am

Hi McMClark,

Yes, but if you want it to be displayed when clicking the series you may better use OnMouseDown event.
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

Post Reply