Hey
I have a TChart on my form and it displays 2 series and a third (hidden) one. Now I have a TCursorTool (snapping and vertical style only) which can be used to select a datapoint. I have datapoints every 15 seconds (timescaled axis). I save the selected point in a database (time-value).
But if I want to reload that chart (for editing), I have absolutley no idea how to set the CursorTool at the estimated point. I know, that for 04:15, it should be the 17th point of the chart. But if I set XValue to any value, it is at the end of my datapoints or at the beginning. I have tested putting out XValue when I move my CursorTool-line and I get very small values (0.00xxxx). I have absolutely no idea how this value is calculated.
Screenshot (like it should be after reloading)
Thanks for any assistance
Edit: Using Delphi 7 with TeeChart Pro 6.01
Setting XValue of TCursorTool
Hi.
If you've setup the Snap property to true then only "good" values are exact point (x) values. If this is not the case (if you want to freely move cursor tool), set the Snap property to false and then manually control cursor tool poisition by using the following code:
If this is not the case, you can use SnapToPoint method to reposition cursor tool to the nearest point:
If you've setup the Snap property to true then only "good" values are exact point (x) values. If this is not the case (if you want to freely move cursor tool), set the Snap property to false and then manually control cursor tool poisition by using the following code:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.XValues.DateTime := True;
// x = 0:12:15
Series1.AddXY(EncodeTime(0,12,15,0),5);
// x = 3:05:00
Series1.AddXY(EncodeTime(3,05,0,0),3);
// x = 12:00:00
Series1.AddXY(EncodeTime(12,0,0,0),6);
// x = 17:03:05
Series1.AddXY(EncodeTime(17,03,05,0),1);
ChartTool1.Snap := False;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ChartTool1.XValue := EncodeTime(10,0,0,0);
end;
Code: Select all
ChartTool1.Snap := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ChartTool1.XValue := EncodeTime(3,0,0,0);
ChartTool1.SnapToPoint;
end;
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
-
- Newbie
- Posts: 5
- Joined: Thu Nov 27, 2003 5:00 am
Thanks lot for the hint with EncodeTime. This does correct placement over the chart. But there's one problem left. I can't set the XValue when the form is visible (OnCreate, OnShow). I have a workaround with a timer setting me the XValue after OnShow, but this isn't a pretty solution. Do you have any ideas? (although it's working now)
-
- Newbie
- Posts: 5
- Joined: Thu Nov 27, 2003 5:00 am