TeeChart 6.01: zoom by code

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
JosefG
Newbie
Newbie
Posts: 10
Joined: Tue Nov 25, 2003 5:00 am

TeeChart 6.01: zoom by code

Post by JosefG » Wed Oct 26, 2011 3:35 pm

Hi,
we still use TeeChart version 6.01.

with 2 CursorTool-Lines the user can define a time-period at the x-axis.
On clicking a button we like to zoom the x-axis (the y-axis should stay the same) in a manner that the period defined by the cursortool-lines stretches to the whole x-axis (zoom-in).
Because we have trouble to code this task, I hope you could help us on this.

Thank you very much for your help,
Josef Gschwendtner

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

Re: TeeChart 6.01: zoom by code

Post by Yeray » Thu Oct 27, 2011 8:10 am

Hello Josef,

I've tried the following code and it seems to respond as expected.

Code: Select all

uses Series, TeeTools;

var Cursor1, Cursor2: TCursorTool;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  Chart1.AddSeries(TFastLineSeries).FillSampleValues();

  Cursor1:=Chart1.Tools.Add(TCursorTool) as TCursorTool;
  Cursor2:=Chart1.Tools.Add(TCursorTool) as TCursorTool;
  Cursor1.Style:=cssVertical;
  Cursor2.Style:=cssVertical;

  Chart1.Draw;
  Cursor1.XValue:=10;
  Cursor2.XValue:=15;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Chart1.Axes.Bottom.SetMinMax(Cursor1.XValue, Cursor2.XValue);
end;
Doesn't it do what you are looking for? Don't hesitate to let us know if you still have problems with it.
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

JosefG
Newbie
Newbie
Posts: 10
Joined: Tue Nov 25, 2003 5:00 am

Re: TeeChart 6.01: zoom by code

Post by JosefG » Thu Oct 27, 2011 10:40 am

Hi Yeray,
thank you for your response. This was not the solution, but now I found out by myself :D

I forgot, that I just have to set the Minimum/Maximum-Property to get the desired behavior.
Chart.Axes.Bottom.Automatic := False;
Chart.Axes.Bottom.Minimum := Round(FCursorToolFrom.XValue);
Chart.Axes.Bottom.maximum := Round(FCursorToolTo.XValue);

Thank you,
Josef

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

Re: TeeChart 6.01: zoom by code

Post by Yeray » Thu Oct 27, 2011 1:33 pm

Hi Josef,

I'm glad to be helpful one way or the other. :D
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

Post Reply