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
Annotation Width
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:
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
http://www.steema.com