Page 1 of 1

Calculating pixel position of annotation callout

Posted: Sat Oct 30, 2010 5:12 am
by 15057312
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

Re: Calculating pixel position of annotation callout

Posted: Tue Nov 02, 2010 3:04 pm
by 10050769
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,