Add Text to Chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
ABPInduction
Newbie
Newbie
Posts: 7
Joined: Fri Dec 23, 2005 12:00 am

Add Text to Chart

Post by ABPInduction » Mon Feb 27, 2006 10:01 am

Dear Sir,
I wanted to add Text to my chart with help of Canvas. Now my Problem is, that my text shouldn't be fixed with pixels, it should be added to the Chart with x, y cordination of the X and Y Axis.
Is it possible?

Next Problem:
I add the text now onAfterDraw. But the text is only visible when zooming. How could I see text text all time?

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 Feb 27, 2006 10:12 am

Hello,

Yes, this is possible doing something like in this code:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues();
  Chart1.Draw;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var X,Y: Integer;
begin
  X:=Chart1.Axes.Bottom.CalcXPosValue(2);
  Y:=Chart1.Axes.Left.CalcYPosValue(100);
  Chart1.Canvas.TextOut(X,Y,'My Custom Text');
end;
Next Problem:
I add the text now onAfterDraw. But the text is only visible when zooming. How could I see text text all time?
This is because you need to force the chart being drawn before calling Draw method as done in the snippet above.
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