Page 1 of 1

Dynamic TAnnotation

Posted: Thu Nov 08, 2007 10:00 am
by 10546935
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

Posted: Fri Nov 09, 2007 9:20 am
by yeray
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);