Scroll location

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
sunman4008
Newbie
Newbie
Posts: 18
Joined: Tue Apr 09, 2013 12:00 am

Scroll location

Post by sunman4008 » Fri Apr 19, 2013 1:18 am

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

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Scroll location

Post by Yeray » Fri Apr 19, 2013 12:04 pm

Hi Mike,

Use the bottom axis SetMinMax function. Pass the "start" and "end" TDateTime you wish to the SetMinMax function.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Scroll location

Post by Sandra » Fri Apr 19, 2013 12:26 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply