Calculating pixel position of annotation callout

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
lilo
Newbie
Newbie
Posts: 61
Joined: Thu Sep 23, 2010 12:00 am

Calculating pixel position of annotation callout

Post by lilo » Sat Oct 30, 2010 5:12 am

I am using the following code to calculate the annotation callout of points on a ternary chart. I am getting the wrong screen coordinates output to the x and y positions of the callout. The result is a line connecting to empty point positions.

Sub PlotTernary
For i = 1 to numberofsamples
Ternary1.Add(XVal(i), YVal(i), ZVal(i), Color(i))
Next i
End Sub

Private Sub TChart1_ClickSeries(ByVal sender As Object, ByVal s As Steema.TeeChart.Styles.Series, ByVal valueIndex As Integer, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TChart1.ClickSeries
SetCallout(valueIndex)
End Sub

Private Sub SetCallout(ByVal AIndex As Integer)
AnnotationChart4.Active = True
' Change annotation text
AnnotationChart4.Shape.AutoSize = True
AnnotationChart4.Text = "Point: " & AIndex.ToString() & " Value: " & Ternary1.ValueMarkText(AIndex)

' Re-position annotation callout
With AnnotationChart4.Callout
.Visible = True
.XPosition = Ternary1.CalcXPos(AIndex)
.YPosition = Ternary1.CalcYPos(AIndex)
.ZPosition = 0
End With

End Sub

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Calculating pixel position of annotation callout

Post by Sandra » Tue Nov 02, 2010 3:04 pm

Hello lilo,

I Hello lilo,
I have modified your code and now works fine for me here. Please, see next code and check if works as you want:

Code: Select all

 Private tChart1 As Steema.TeeChart.TChart
    Public Sub New()
        InitializeComponent()
        tChart1 = New Steema.TeeChart.TChart()
        Me.Controls.Add(tChart1)
        tChart1.Dock = DockStyle.Fill

        InitializeChart()
    End Sub
    Private tool1 As Steema.TeeChart.Tools.Annotation
    Private Sub InitializeChart()
        tool1 = New Steema.TeeChart.Tools.Annotation(tChart1.Chart)
        tool1.Active = False
        Dim series1 As New Steema.TeeChart.Styles.Ternary(tChart1.Chart)
        series1.FillSampleValues(5)
        AddHandler tChart1.ClickSeries, AddressOf tChart1_ClickSeries
    End Sub
    Private Sub tChart1_ClickSeries(ByVal sender As Object, ByVal s As Steema.TeeChart.Styles.Series, ByVal valueIndex As Integer, ByVal e As MouseEventArgs)
        SetCallout(valueIndex, e.X, e.Y)
    End Sub

    Private Sub SetCallout(ByVal valueIndex As Integer, ByVal valueX As Integer, ByVal valueY As Integer)
        tool1.Active = True
        tool1.Shape.AutoSize = True
        tool1.Text = "Point:" & valueIndex.ToString() & "Value:" & tChart1(0).ValueMarkText(valueIndex)
        tool1.Callout.Visible = True
        tool1.Callout.XPosition = valueX
        tool1.Callout.YPosition = valueY
        tool1.Callout.ZPosition = 0
    End Sub
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply