home *** CD-ROM | disk | FTP | other *** search
- {*********************************************}
- { TeeChart Pro 4 example }
- { Copyright (c) 1995-1998 by David Berneda }
- { All rights reserved }
- {*********************************************}
- unit Ufitaxis;
-
- interface
-
- { This example resets the Axis scales to the minimum and
- maximum values of Series points in a single page.
-
- By default, the minimum and maximum are calculated using
- ALL pages.
- This example shows how to fit points in a single page.
- }
- uses
- WinTypes,WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- TeEngine, Series, ExtCtrls, TeeProcs, Chart, StdCtrls;
-
- type
- TFormFitAxis = class(TForm)
- Chart1: TChart;
- Series1: TBarSeries;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- procedure FormCreate(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure Chart1PageChange(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- Procedure CalcAxis;
- end;
-
- var
- FormFitAxis: TFormFitAxis;
-
- implementation
-
- {$R *.DFM}
-
- procedure TFormFitAxis.FormCreate(Sender: TObject);
- begin
- Series1.FillSampleValues(80); { sample values }
- end;
-
- { calculate the minimum and maximum }
- Procedure TFormFitAxis.CalcAxis;
- var t:Integer;
- tmp,tmpMin,tmpMax:Double;
- begin
- tmpMin:=0;
- tmpMax:=0;
- { loop of visible points in current page... }
- for t:=Series1.FirstValueIndex to Series1.LastValueIndex do
- begin
- tmp:=Series1.YValues[t];
- if tmp<tmpMin then tmpMin:=tmp; { calculate minimum }
- if tmp>tmpMax then tmpMax:=tmp; { calculate maximum }
- end;
- Series1.GetVertAxis.SetMinMax(tmpMin,tmpMax); { set axis scales }
- end;
-
- procedure TFormFitAxis.Button2Click(Sender: TObject);
- begin
- Chart1.NextPage;
- end;
-
- procedure TFormFitAxis.Button1Click(Sender: TObject);
- begin
- Chart1.PreviousPage;
- end;
-
- procedure TFormFitAxis.Button3Click(Sender: TObject);
- begin
- CalcAxis;
- end;
-
- procedure TFormFitAxis.Button4Click(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TFormFitAxis.Chart1PageChange(Sender: TObject);
- begin
- Chart1.LeftAxis.AdjustMaxMin;
- Chart1.BottomAxis.AdjustMaxMin;
- Series1.CalcFirstLastVisibleIndex;
- CalcAxis;
- end;
-
- end.
-