.Locate funtion is not precise

TeeChart for ActiveX, COM and ASP
Post Reply
andrzej
Newbie
Newbie
Posts: 1
Joined: Fri Dec 12, 2003 5:00 am
Location: Poland

.Locate funtion is not precise

Post by andrzej » Fri Jan 09, 2004 11:10 am

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

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Jan 12, 2004 9:56 am

Hi Andrzej,

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
Josep Lluis Jorge
http://support.steema.com

Post Reply