Page 1 of 1

Moving Cursor under Program Control

Posted: Sun Apr 24, 2005 6:16 pm
by 9236155
I have a vertical cursor MyCursor (type TCursorTool) and have set the following statements in my program:-

MyCursor:=TCursorTool.Create(Self);
MyCursor.ParentChart:=Chart1;
MyCursor.Series:=Series1;
MyCursor.FollowMouse:=true;
MyCursor.Style:=cssVertical;
MyCursor.Visible:=true;
MyCursor.UseChartRect:=true;
MyCursor.snap:=true;

The manual cursor movement is fine. How does one force the cursor under program control to the last point in Series1. I need to do this so that the cursor highlights the most current data of stock prices.

Will appreciate ideas/suggestions.

Satish

Posted: Mon Apr 25, 2005 7:53 am
by narcis
Hi Satish,

You should use:

Code: Select all

MyCursor.XValue:=Series1.XValue[Series1.Count-1];
However it doesn't work properly. I've done some testing and the why to get it work is:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues();

  ChartTool1.XValue:=Series1.XValue[Series1.Count-1];
end;

procedure TForm1.Chart1BeforeDrawSeries(Sender: TObject);
begin
    ChartTool1.XValue:=Series1.XValue[Series1.Count-1];
end;
It's weird but this is the combination that works by now. I've already introduced this to our deffect list to be fixed for our next releases.

Posted: Tue Apr 26, 2005 7:12 pm
by 9236155
Narcis,

Thanks - this works fine when I bring up the chart first time. When I move to another chart (by clicking a button) the cursor really does not go to the last date. Do I need to refresh/repaint the chart/series for this ?

Regards,

Satish

Posted: Wed Apr 27, 2005 7:18 am
by narcis
Hi Satish,

Are you positioning the cursor to the last value after populating the chart and at OnBeforeDrawSeries event for the other charts?

If you are doing this and still doesn't work please send un an application we can run "as-is" to reproduce the problem here. Please send your examples at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.