Dynamic TAnnotation

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Pete
Newbie
Newbie
Posts: 2
Joined: Fri Oct 05, 2007 12:00 am

Dynamic TAnnotation

Post by Pete » Thu Nov 08, 2007 10:00 am

I'm pretty new to the TChart stuff, so this is most likely pretty easy to solve. but right now I'm stuck.

I created a chart (dynamically at runtime) and added some series ... not problem so far. Now I need to add a kind of lable to some of the series. The lable shoulb be displayed within the chart so I looked around and found the TAnnotationTool. That should do what I want and should be easy to use. Here is what I did:

Code: Select all

	TAnnotationTool* annotation = new TAnnotationTool(pChart);
	annotation->Shape->CustomPosition = true;
	annotation->Shape->Left = 65;
	annotation->Shape->Top = 125;
	annotation->Text = "Annotation 1";
pChart is the initialized and visible TChart object (I was'n sure about the constructor parameter and tried a series pointer as well). Actually I adaped the code from a Delphi example found somewhere on the net.

The code copiles fine, but when I run the application I get a Runtime error "Access violation at address 4207A0B in Module 'Tee710.bpl'. Read of address 00000000.". If I stop in the debugger I can not see that there is anything wrong with the annotation object. But obviously I'm missing something.

Can anyone help with that, pls? Or is there another solution to add a text lable to the chart?

Thx

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

Post by Yeray » Fri Nov 09, 2007 9:20 am

Hi Pete,

You need to add the tool to the chart once created, doing something like the following:

Code: Select all

pChart->Tools->Add(annotation);
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