Page 1 of 1
Cursor Tool manual position change
Posted: Wed Aug 09, 2006 9:02 am
by 9790349
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
Posted: Wed Aug 09, 2006 9:37 am
by Chris
Hello,
How about setting the Cursor.XValue and Cursor.YValue within the TChart click event?
Posted: Wed Aug 09, 2006 9:54 am
by 9790349
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
Posted: Wed Aug 09, 2006 10:00 am
by Chris
Hello,
Code: Select all
CursorTool1.XValue = DateTime.FromOADate(P.X);
should do it.
Posted: Wed Aug 09, 2006 10:24 am
by 9790349
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
Posted: Wed Aug 09, 2006 10:54 am
by Chris
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;
}