Ok, this should be neat.
I basically want to move my cursor to the point with which an entry of a number in a cell has occurred. I have all the events in place.
Do I set the YValue of the cursor to move or the XValue? Id assume the XValue but how do I calculate the position. And of course the value entered may not be the exact number available in the series, so how does that play out to get the nearest point?
Thanks,
Tom
Moving Cursor with StringGrid Entry...
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Tom,
You may be interested in using Locate method as shown here:
You may be interested in using Locate method as shown here:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var Index: Integer;
begin
Series1.YValues[5]:=10;
Index:=Series1.YValues.Locate(Series1.YValues[5]);
ChartTool1.YValue:=Series1.YValues[Index];
ChartTool1.XValue:=Series1.XValues[Index];
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Tom,
Then the only way I can think of is doing something like this:
Then the only way I can think of is doing something like this:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
i, SeriesIndex: Integer;
Val, ApproxVal, Diff, tmpDiff: Double;
begin
Val:=500;
ApproxVal:=499.5;
Series1.YValues[5]:=Val;
Diff:=Series1.MaxYValue;
SeriesIndex:=-1;
for i:=0 to Series1.Count do
begin
tmpDiff := Series1.YValue[i] - ApproxVal;
if Abs(tmpDiff) < Diff then
begin
Diff:=tmpDiff;
SeriesIndex:=i;
end;
end;
ChartTool1.YValue:=Series1.YValues[SeriesIndex];
ChartTool1.XValue:=Series1.XValues[SeriesIndex];
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |