how to let one Annotation responsed to Click or doubleclick

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Richard
Newbie
Newbie
Posts: 40
Joined: Mon May 21, 2001 4:00 am

how to let one Annotation responsed to Click or doubleclick

Post by Richard » Wed Jan 07, 2009 8:01 am

i add two annotations on one chart,when click one annotation,how to response with one funciton.

showMessage('this is one annation') or do other things

thanks a lot

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

Post by Narcís » Wed Jan 07, 2009 9:08 am

Hi Richard,

You can use its OnClick event, for example:

Code: Select all

procedure TForm1.ChartTool1Click(Sender: TAnnotationTool;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ShowMessageUser('this is my annotation!');
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

Richard
Newbie
Newbie
Posts: 40
Joined: Mon May 21, 2001 4:00 am

Post by Richard » Wed Jan 07, 2009 9:27 am

thanks a lot for your response.

i dynamicly add many annotationtool in order to show some text. and how can i dynamicly text.i can't find the property.

do you have other good way to solve this problem that i only want to show some digital numer and text dynamicly.

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

Post by Narcís » Wed Jan 07, 2009 9:43 am

Hi Richard,

Yes, you can also assign the event dynamically as shown here:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  ChartTool1.OnClick:=ChartTool1Click;
end;

procedure TForm1.ChartTool1Click(Sender: TAnnotationTool;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ShowMessageUser(Sender.Text);
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

Richard
Newbie
Newbie
Posts: 40
Joined: Mon May 21, 2001 4:00 am

Post by Richard » Wed Jan 07, 2009 9:59 am

Code: Select all

procedure TForm1.FormCreate(Sender: TObject); 
begin 
Chart1.RemoveAllSeries;
  Chart1.Tools.Clear;
 chart1.tools.add(Tannotationtool);
chart1.tools.add(Tannotationtool);
chart1.tools.add(Tannotationtool);
chart1.tools.add(Tannotationtool);
end; 
when i click one annatation ,
how to reponse with mouseEvent. thanks a lot.

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

Post by Narcís » Wed Jan 07, 2009 10:15 am

Hi Richard,

I'm sorry but I'm not sure about what you are trying to achieve here. Could you please give us some more details about it?

Thanks in advance.
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

Richard
Newbie
Newbie
Posts: 40
Joined: Mon May 21, 2001 4:00 am

Post by Richard » Thu Jan 08, 2009 2:48 am

Code: Select all

procedure TMainForm.ResetChart;
var tmpEmpty:TChart;
begin
  Chart1.RemoveAllSeries;
  Chart1.Tools.Clear;
  tmpEmpty:=TChart.Create(nil);
  try
    tmpEmpty.AllowZoom:=False;
    tmpEmpty.AllowPanning:=pmNone;
    tmpEmpty.Color:=clWhite;
    Chart1.Assign(tmpEmpty);
  finally
    tmpEmpty.Free;
  end;
end;
procedure TMainForm.Button2Click(Sender: TObject);
var
  tmpChart:TCustomChart;
begin
   ResetChart;
   tmpChart:=TCustomChart(Chart1);
   LoadchartFromfile(tmpchart,'test.tee');
   Chart1:=TChart(tmpChart);
   Chart1.BackImage.LoadFromFile('turbine.gif');
   chart1.BackImageMode:=pbmCenter;
 //chart1.Tools.items[0].onClick ?

end;


chart1.Tools.items[0].onClick ?
There's no this function

thanks a lot for your focusing on this.
I have used the TeeChart office to edit the customized chart(test.tee file),and when I loaded the file ,and I now want to set the Tannotationtool's click property to realize some functions. Can you tee me how to do this.

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

Post by Narcís » Thu Jan 08, 2009 8:32 am

Hi Richard,

In that case you need to typecast the tools like this:

Code: Select all

  for i:=0 to Chart1.Tools.Count-1 do
    if Chart1.Tools.Items[i] is TAnnotationTool then
      (Chart1.Tools.Items[i] as TAnnotationTool).OnClick:=ChartTool1Click;
Hope this helps!
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