Page 1 of 1

Scroll location

Posted: Fri Apr 19, 2013 1:18 am
by 16565592
Hello,

I have 2 candlestick series with Teechart. One is the candlestick from 1 year ago going to today. The second is the future price projection.

Right now, when the chart is loaded, it comes the beginning of the historical year i.e far left. How do I move the scroll position so current date is shown in the middle of the screen.?


-Mike

Re: Scroll location

Posted: Fri Apr 19, 2013 12:04 pm
by yeray
Hi Mike,

Use the bottom axis SetMinMax function. Pass the "start" and "end" TDateTime you wish to the SetMinMax function.

Re: Scroll location

Posted: Fri Apr 19, 2013 12:26 pm
by 10050769
Hello Mike,

An example that allows you achieve the suggestion of Yeray, is using similar code as next:

Code: Select all

Uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var Series1:TLineSeries;
dif:double;
t:Integer;
today: TDateTime;
begin
today:= Now;
Series1 := TLineSeries.Create(self);
Chart1.AddSeries(Series1);
Chart1.View3D:=false;
//previous
Series1.AddXY(EncodeDate(2011, 4, 10), Random(10));
Series1.XValues.DateTime:=true;
for t := 1 To 25 do
    Series1.AddXY(EncodeDate(2013, 4, t), Random(t));

//Future
Series1.AddXY(EncodeDate(2013, 6, 10), Random(10));
Chart1.Axes.Bottom.LabelsAngle:= 90;
Chart1.Axes.Bottom.SetMinMax(today-5, today+5);
 Chart1.Axes.Bottom.Increment := DateTimeStep[dtOneDay];
Chart1.Axes.Bottom.MinimumOffset :=40;
Chart1.Axes.Bottom.MaximumOffset := -20;
I hope will helps.

Thanks,