lazarus/components/tachart/demo/axistransf/main.pas
2011-01-29 01:53:03 +00:00

94 lines
2.2 KiB
ObjectPascal

unit Main;
{$mode objfpc}{$H+}
interface
uses
ComCtrls, ExtCtrls, Forms, StdCtrls, TAFuncSeries, TAGraph,
TASeries, TASources, TAStyles, TATools, TATransformations;
type
{ TForm1 }
TForm1 = class(TForm)
catTAutoAutoScaleAxisTransform1: TAutoScaleAxisTransform;
catTAutoScaleAxisTransform1: TAutoScaleAxisTransform;
catTAuto: TChartAxisTransformations;
cbAuto: TCheckBox;
csStripes: TChartStyles;
ChartLog: TChart;
cfsLog: TFuncSeries;
cbLog: TCheckBox;
ChartTWinterBar: TBarSeries;
clsLogPoints: TLineSeries;
ChartT: TChart;
catLog: TChartAxisTransformations;
ChartAxisTransformations1LinearAxisTransform2: TLinearAxisTransform;
ChartAxisTransformations1LogarithmAxisTransform1: TLogarithmAxisTransform;
catT: TChartAxisTransformations;
catTFahrToCel: TLinearAxisTransform;
ChartTSummer: TLineSeries;
ChartTWinterLine: TLineSeries;
PageControl1: TPageControl;
pnlLogControls: TPanel;
pnlAutoControls: TPanel;
rcsTSummer: TRandomChartSource;
rcsTWinter: TRandomChartSource;
lsLinear: TTabSheet;
tsLog: TTabSheet;
procedure cbAutoChange(Sender: TObject);
procedure cbLogChange(Sender: TObject);
procedure ChartLogFuncSeries1Calculate(const AX: Double; out AY: Double);
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
uses
Math, SysUtils, TAChartAxis, TAChartUtils;
{$R *.lfm}
function MyFunc(AX: Double): Double;
begin
Result := Power(10, AX) + 3;
end;
{ TForm1 }
procedure TForm1.cbAutoChange(Sender: TObject);
begin
catTAutoAutoScaleAxisTransform1.Enabled := cbAuto.Checked;
catTAutoScaleAxisTransform1.Enabled := cbAuto.Checked;
end;
procedure TForm1.cbLogChange(Sender: TObject);
begin
ChartAxisTransformations1LogarithmAxisTransform1.Enabled := cbLog.Checked;
end;
procedure TForm1.ChartLogFuncSeries1Calculate(const AX: Double; out AY: Double);
begin
AY := MyFunc(AX);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
x: Double;
begin
for i := 0 to 50 do begin
with cfsLog.Extent do
x := i / 50 * (XMax - XMin) + XMin;
clsLogPoints.AddXY(x + Random - 0.5, MyFunc(x) + Random - 0.5);
end;
end;
end.