Get BottomAxis Value

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Kev
Newbie
Newbie
Posts: 7
Joined: Wed Jan 03, 2007 12:00 am

Get BottomAxis Value

Post by Kev » Wed Mar 28, 2007 2:09 am

How can I get the BottomAxis Label for a given ColorLine->Value obtained in the ChartTool->DragLine() event?

thanks,
kev

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

Post by Yeray » Wed Mar 28, 2007 8:59 am

Hello Kev,

the following example shows you two ways to achieve it:

Code: Select all

procedure TForm1.ChartTool1DragLine(Sender: TColorLineTool);
var x, y, index: Integer;
begin
  x:=Series1.CalcXPosValue(ChartTool1.Value);

//first way
  for y:=Chart1.Axes.Left.IStartPos to Chart1.Axes.Left.IEndPos do
       if Series1.Clicked(x,y)<>-1 then index:=Series1.Clicked(x,y);

//second way, more restrictive. Will only show the label when your dragline is placed exactly on a series point.
//  index:=Series1.XValues.Locate(ChartTool1.Value);

  if index<>-1 then
     Chart1.Title.Caption := Series1.Labels[index];
end;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Series1.Clear;

  for i:=0 to 10 do
    Series1.Add(Random,'label ' + IntToStr(i));
end;
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