Hello,
pls is it possible to access label set up with:
TChartSpeed.Series(1).AddXY 92 , 1001.07 , "sample label" , RGB(255,0,0)
in mouse event:
Sub TChartSpeed_OnMouseMove(Shift, X, Y)
???
I would like to display this label with yvalues in rectangle with annotation tool.
thanks
asp label access
Hi adenin,
If I understand well, you are trying to achieve something very similar than All Features/Tools/Annotation/Annotation Callout example in the new features demo, available at TeeChart's program group.
If I understand well, you are trying to achieve something very similar than All Features/Tools/Annotation/Annotation Callout example in the new features demo, available at TeeChart's program group.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
yes, something like that;
I have already found it:
Sub TChartSpeed_OnMouseMove(Shift, X, Y)
mouseOverIndex = TChartSpeed.Series(1).Clicked(X, Y)
If mouseOverIndex <> -1 Then
TChartSpeed.Tools.Items(0).Active=True
TChartSpeed.Tools.Items(0).asAnnotation.Text = "value:" & TChartSpeed.Series(1).YValues.Value(mouseOverIndex) & Chr(13) & "label:" & TChartSpeed.Series(1).PointLabel(mouseOverIndex)
...
I have already found it:
Sub TChartSpeed_OnMouseMove(Shift, X, Y)
mouseOverIndex = TChartSpeed.Series(1).Clicked(X, Y)
If mouseOverIndex <> -1 Then
TChartSpeed.Tools.Items(0).Active=True
TChartSpeed.Tools.Items(0).asAnnotation.Text = "value:" & TChartSpeed.Series(1).YValues.Value(mouseOverIndex) & Chr(13) & "label:" & TChartSpeed.Series(1).PointLabel(mouseOverIndex)
...
Hi adenin,
I've made an example using two functions in the demo I've pointed to you before. Note that for me, the series index is 0, and for you is 1.
I've made an example using two functions in the demo I've pointed to you before. Note that for me, the series index is 0, and for you is 1.
Code: Select all
Private Sub Form_Load()
With TChart1
.Aspect.View3D = False
.Legend.Visible = False
.AddSeries scPoint
For i = 0 To 49
.Series(0).AddXY i, Rnd * 1000, "Point number " + Str$(i), RGB(255, 0, 0)
Next i
.Axis.Bottom.Labels.Style = talValue
With .Tools
.Add tcAnnotate
With .Items(0).asAnnotation
.Left = 300
.Top = 15
.Text = TChart1.Series(0).PointLabel(0)
End With
End With
End With
End Sub
' Returns Series point index that is nearest to xy position.
Function NearestPoint(ByVal X As Long, ByVal Y As Long) As Long
Dim Difference As Long, tmpDif As Long, i As Long, res As Long
res = -1
Difference = -1
For i = 0 To TChart1.Series(0).Count - 1
tmpDif = Round(TeeDistance(TChart1.Series(0).CalcXPos(i) - X, _
TChart1.Series(0).CalcYPos(i) - Y))
If (Difference = -1) Or (tmpDif < Difference) Then
Difference = tmpDif
res = i
End If
Next i
NearestPoint = res
End Function
Function TeeDistance(ByVal X As Integer, ByVal Y As Integer) As Double
TeeDistance = Sqr(X ^ 2 + Y ^ 2)
End Function
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim i As Integer
i = NearestPoint(X, Y)
TChart1.Tools.Items(0).asAnnotation.Text = TChart1.Series(0).PointLabel(i)
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |