How to automatically move annotation?

TeeChart for ActiveX, COM and ASP
Post Reply
David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

How to automatically move annotation?

Post by David » Fri Jul 21, 2006 3:52 am

Hi,

I added some annotation at certain x values of a fastline series. When the x value continues to grow, the max x-axis value will automatically increase and I manually set the x-min so that all the data can be displayed. However, when the axis range increases, the annotation is alwasy fixed at their old positions and the new ones are overlapped. Is there any way to automatically move the annotation based on the latest position of the x values they combined with?

Thank you very much!
David

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Jul 24, 2006 7:01 am

Hi David,

yes, to move them with the axis you will have to define their positions relative to other TeeChart objects and not as absolute pixel positions. Unfortunately the default positions are absolute pixel positions.
For example, you'll have to use code similar to the following (this is used to print at annotations at correct position but uses the same trick) :

Code: Select all

Private Sub Command1_Click()
TChart1.Printer.ShowPreview
End Sub

Private Sub Form_Load()
With TChart1
    .AddSeries scLine
    .Series(0).FillSampleValues 10
    .Tools.Add tcAnnotate
    With .Tools.Items(0).asAnnotation
        .Text = "HELLO"
    End With
End With
End Sub

Private Sub TChart1_OnBeforeDrawSeries()
With TChart1
    With .Tools.Items(0).asAnnotation
        .Shape.CustomPosition = True
        .Shape.Left = TChart1.Axis.Left.Position - 30
        .Shape.Top = TChart1.Axis.Top.Position - 30
    End With
End With
End Sub

Post Reply