How to change the point annotation location from the default for point chart

Hany Metry 41 Reputation points
2023-11-30T16:43:51.28+00:00

Hi,

How to change the point annotation location from the default for point chart.

For Findex As Integer = 0 To MyAnnos.Count - 1                         
Dim PC As New TextAnnotation                         
With PC                             
.ForeColor = Color.Red                             
.Font = New Font("Tahoma", 10)                             
.AnchorDataPoint = Chart1.Series("Interaction Diagram3").Points(MyAnnos(Findex).SeriesFindex)                             
.X = Chart1.Series("Interaction Diagram3").Points(MyAnnos(Findex).SeriesFindex).XValue                             .Y = Chart1.Series("Interaction Diagram3").Points(MyAnnos(Findex).SeriesFindex).YValues(0)                             .Text = MyAnnos(Findex).MTindex.ToString & " " & PC.AnchorDataPoint.ToString                             Chart1.Annotations.Add(PC)                         
End With                     
Next
Developer technologies | VB
Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2023-12-01T07:56:22.7266667+00:00

    Hi @Hany Metry ,

    Modify the X and Y coordinates of the TextAnnotation then add it into your chart.

    For Findex As Integer = 0 To MyAnnos.Count - 1
        Dim PC As New TextAnnotation()
        With PC
            .ForeColor = Color.Red
            .Font = New Font("Tahoma", 10)
            .AnchorDataPoint = Chart1.Series("Interaction Diagram3").Points(MyAnnos(Findex).SeriesFindex)
            
            .X = Chart1.Series("Interaction Diagram3").Points(MyAnnos(Findex).SeriesFindex).XValue + 0.5
            .Y = Chart1.Series("Interaction Diagram3").Points(MyAnnos(Findex).SeriesFindex).YValues(0) + 10
    
            .Text = MyAnnos(Findex).MTindex.ToString() & " " & PC.AnchorDataPoint.ToString()
            Chart1.Annotations.Add(PC)
        End With
    Next
    
    

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.