TeeChart Pro v6.0.0.4
I use Annotation Tool with Pointer to manually show the current value of series on MouseMove event. I ve got a series (scLine) with values range: 10-30 on X and 0.123-0.125 on Y. Furthermore this is quite steep line on the screen.
I pass XY mouse coordinates to my function in witch I use following:
idx = TChart.Series(0).XValues.Locate(Round(TChart.Series(0).XScreenToValue(X)))
ValueX = TChart.Series(0).XScreenToValue(X)
ValueY = TChart.Series(0).YValues.Value(idx)
With TChart.Tools(0).asAnnotation.Callout
.XPosition = X
.YPosition = TChart.Series(0).CalcYPos(idx)
End with
The problem is:
I cannot pass double with decimal places to .Locate function because the return value is always -1. Only integer numbers are accepted. Therefore I use Round() function. Of course this is not sufficient.
The problem produce the effect of pointer step walking on screen.
Furthermore I checked the following:
TChart.Series(0).XValues.Value(mIndex)
where mIndex was eg. 338,339,340,...
This does not return numbers with decimal places eg. for mIndex range of 339-348 function returns the same value 26 and beyond 348 returns 27 and so on.
I tested also Cursor Tool and the problem is similar. XVal returns only integer numbers.
I need to show pointer precisely. Any ideas?
Thanks.
Andrzej
.Locate funtion is not precise
Hi Andrzej,
to do this you can use similar code to the following (using the Canvas, XScreenToValue and YScreenToValue methods) :
Josep Lluis Jorge
http://support.steema.com
to do this you can use similar code to the following (using the Canvas, XScreenToValue and YScreenToValue methods) :
Code: Select all
Dim OnSeriesPoint As Boolean
Dim tmpL2 As Integer
Private Sub Form_Load()
TChart1.Series(0).FillSampleValues 10
TChart1.Axis.Bottom.Labels.DateTimeFormat = "dd/mm/yy hh:mm:ss"
tmpL2 = 1000
End Sub
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim tmp, tmpL As Integer
With TChart1
If .Series(0).Clicked(X, Y) <> -1 And OnSeriesPoint = False Then
.Canvas.Brush.Style = bsSolid
.Canvas.Pen.Color = vbBlack
.Canvas.Brush.Color = vbWhite
.Canvas.TextOut X + 10, Y, TChart1.Axis.Bottom.Labels.FormattedValue(.Series(0).XScreenToValue(X)) _
& ", " & Str$(TChart1.Axis.Left.Labels.FormattedValue(.Series(0).YScreenToValue(Y)))
OnSeriesPoint = True
End If
'Repaint Chart to clear Textoutputted Mark
If .Series(0).Clicked(X, Y) = -1 And OnSeriesPoint = True Then
OnSeriesPoint = False
.Repaint
End If
End With
End Sub
http://support.steema.com