Annotation Width

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Ed
Newbie
Newbie
Posts: 33
Joined: Tue Mar 09, 2004 5:00 am
Location: Oregon, USA
Contact:

Annotation Width

Post by Ed » Thu May 27, 2004 6:07 pm

Old problem, new priority :-)

I am trying to position annotations in the middle of a series. I can get the middle of the series correctly:

lLeft := aSeries.CalcXPos(lLeft);
lRight := aSeries.CalcXPos(lRight);
lSeriesMiddle := lLeft + ((lRight-lLeft) div 2);

but when I try to get the annotation width:


lAnnWidth := aAnnTool.Shape.ShapeBounds.Right - aAnnTool.Shape.ShapeBounds.Left;

I always get the right value to be zero--the Right and Bottom parts of the TRect are both zero.

I am using the TChart.OnBeforeDrawSeries event to set their position. Is there a different event I should be using?

Thanks
Ed Dressel

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Jun 01, 2004 6:40 am

Hi, Ed.

The "problem" is if annotion tool width/height is set automatically (by calculating the space needed to accomodate text) the ShapeBounds rect is always set to (0,0,0,0). To get the auto-sized annotation toll width/height, you can use the following code:

Code: Select all

type TAnnotationAccess = class(TAnnotationTool);

procedure TForm1.Button1Click(Sender: TObject);
var R: TRect;
    w: Integer;
    dummynum,dummyx,dummyy: Integer;
begin
  R := TAnnotationAccess(ChartTool1).GetBounds(dummynum,dummyx,dummyy);
  ShowMessage('Width = '+IntToStr(R.Right-R.Left));
end;

Marjan Slatinek,
http://www.steema.com

Post Reply