Cursor Tool manual position change

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
madve
Newbie
Newbie
Posts: 52
Joined: Thu Feb 16, 2006 12:00 am

Cursor Tool manual position change

Post by madve » Wed Aug 09, 2006 9:02 am

Hi,

I want to set the XValue of the Vertical CursorTool when user clicks on Chart. I have DateTime Bottom Axis.

How can I do that?

(I want to read interpolated values of all series with cursortool according to "Interpolating line series" example in TeeChart .NET demo)

Thanks in advance,

Gabor Varga

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed Aug 09, 2006 9:37 am

Hello,

How about setting the Cursor.XValue and Cursor.YValue within the TChart click event?
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

madve
Newbie
Newbie
Posts: 52
Joined: Thu Feb 16, 2006 12:00 am

Post by madve » Wed Aug 09, 2006 9:54 am

Hi,

I used the following code:

Code: Select all

var
  P : Point;
begin
  P := TChart1.PointToClient( Cursor.Position );
  CursorTool1.XValue :=  P.X;
The problem is that Bottom axis is DateTime. CursorTool XValue must have a datetime in double.

for example:

Code: Select all

CursorTool1.XValue := DateTime.Now.AddDays(1).ToOADate ;
How can I transform Cursor.Position.X to to datetime?

Best regards,

Gabor Varga

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed Aug 09, 2006 10:00 am

Hello,

Code: Select all

CursorTool1.XValue = DateTime.FromOADate(P.X);
should do it.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

madve
Newbie
Newbie
Posts: 52
Joined: Thu Feb 16, 2006 12:00 am

Post by madve » Wed Aug 09, 2006 10:24 am

Hi,
CursorTool1.XValue = DateTime.FromOADate(P.X);
I get the following error:

[Pascal Error] WinForm.pas(556): E2010 Incompatible types: 'Double' and 'DateTime'

So, i think you don't understand what I want thanks to my poor English... :(

I want to move programatically the position of the CursorTool where the user on the TeeChart clicked.

I can get X, Y position of the mouse click with from Cursor.Position but it is not in correlation with Bottom axis!!

Example:

When I click left side of the TeeChart I get X = 0. But when I set CursorTool1.XValue to 0 when Bottom Axis format is DateTime the position of the CursorTool will be somewhere in the past (maybe at 1970.01.01).

|
|
|------A
|........|
|........|
|........|
|------|------|------------------------ Bottom Axis
1:00 2:00 3:00

(dots are nothing)

So, when user clicks to position "A" I can get the Position of the click in points but _not_ the datetime on the Bottom Axis (in example today 02:00).

I hope I could clarify my problem.

Best regards,

Gabor Varga

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed Aug 09, 2006 10:54 am

Hello,

Thank you for your clear explanation. Try the following:

Code: Select all

private void tChart1_ClickBackground(object sender, MouseEventArgs e)
    {
      double xvalue = tChart1.Axes.Bottom.CalcPosPoint(e.X);
      cursorTool1.XValue = xvalue;
    }
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply