Page 1 of 1

How to automatically move annotation?

Posted: Fri Jul 21, 2006 3:52 am
by 9529132
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

Posted: Mon Jul 24, 2006 7:01 am
by Pep
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