mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 20:56:14 +02:00
TAChart: Extract axis transformation demo from the axis demo
git-svn-id: trunk@29240 -
This commit is contained in:
parent
7fc18c2cb1
commit
76b33a7035
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -2239,6 +2239,10 @@ components/tachart/demo/axis/axisdemo.lpi svneol=native#text/plain
|
||||
components/tachart/demo/axis/axisdemo.lpr svneol=native#text/pascal
|
||||
components/tachart/demo/axis/main.lfm svneol=native#text/plain
|
||||
components/tachart/demo/axis/main.pas svneol=native#text/pascal
|
||||
components/tachart/demo/axistransf/axistransfdemo.lpi svneol=native#text/plain
|
||||
components/tachart/demo/axistransf/axistransfdemo.lpr svneol=native#text/pascal
|
||||
components/tachart/demo/axistransf/main.lfm svneol=native#text/plain
|
||||
components/tachart/demo/axistransf/main.pas svneol=native#text/pascal
|
||||
components/tachart/demo/basic/demo.lpi svneol=native#text/plain
|
||||
components/tachart/demo/basic/demo.lpr svneol=native#text/plain
|
||||
components/tachart/demo/basic/unit1.lfm svneol=native#text/plain
|
||||
|
@ -56,7 +56,7 @@
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="9"/>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
|
@ -14,179 +14,10 @@ object Form1: TForm1
|
||||
Height = 333
|
||||
Top = 0
|
||||
Width = 533
|
||||
ActivePage = lsLinear
|
||||
ActivePage = tsCustomMarks
|
||||
Align = alClient
|
||||
TabIndex = 0
|
||||
TabOrder = 0
|
||||
object lsLinear: TTabSheet
|
||||
Caption = 'Linear transform'
|
||||
ClientHeight = 307
|
||||
ClientWidth = 525
|
||||
object ChartT: TChart
|
||||
Left = 0
|
||||
Height = 278
|
||||
Top = 0
|
||||
Width = 525
|
||||
AxisList = <
|
||||
item
|
||||
Grid.Visible = False
|
||||
Marks.LabelFont.Color = clRed
|
||||
Marks.AtDataOnly = True
|
||||
TickColor = clRed
|
||||
Title.LabelFont.Color = clRed
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Summer temperature, °C'
|
||||
Transformations = catTAuto
|
||||
end
|
||||
item
|
||||
Alignment = calBottom
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Year'
|
||||
end
|
||||
item
|
||||
Alignment = calRight
|
||||
Grid.Visible = False
|
||||
Marks.Distance = 4
|
||||
Marks.LabelFont.Color = clBlue
|
||||
Marks.AtDataOnly = True
|
||||
TickColor = clBlue
|
||||
Title.LabelFont.Color = clBlue
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Winter temperature, °F'
|
||||
Transformations = catT
|
||||
end>
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Frame.Visible = False
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Font.Color = clBlue
|
||||
Title.Text.Strings = (
|
||||
'TAChart'
|
||||
)
|
||||
Align = alClient
|
||||
ParentColor = False
|
||||
object ChartTSummer: TLineSeries
|
||||
AxisIndexY = 0
|
||||
LinePen.Color = clRed
|
||||
LinePen.Width = 2
|
||||
Source = rcsTSummer
|
||||
end
|
||||
object ChartTWinterLine: TLineSeries
|
||||
AxisIndexY = 2
|
||||
LinePen.Color = clBlue
|
||||
LinePen.Width = 2
|
||||
Source = rcsTWinter
|
||||
end
|
||||
object ChartTWinterBar: TBarSeries
|
||||
AxisIndexY = 2
|
||||
BarBrush.Color = clBlue
|
||||
BarBrush.Style = bsDiagCross
|
||||
Source = rcsTWinter
|
||||
end
|
||||
end
|
||||
object pnlAutoControls: TPanel
|
||||
Left = 0
|
||||
Height = 29
|
||||
Top = 278
|
||||
Width = 525
|
||||
Align = alBottom
|
||||
ClientHeight = 29
|
||||
ClientWidth = 525
|
||||
TabOrder = 1
|
||||
object cbAuto: TCheckBox
|
||||
Left = 4
|
||||
Height = 17
|
||||
Top = 5
|
||||
Width = 70
|
||||
Caption = 'Auto scale'
|
||||
OnChange = cbAutoChange
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
object tsLog: TTabSheet
|
||||
Caption = 'Logarithm transform'
|
||||
ClientHeight = 307
|
||||
ClientWidth = 525
|
||||
object ChartLog: TChart
|
||||
Left = 0
|
||||
Height = 278
|
||||
Top = 0
|
||||
Width = 525
|
||||
AxisList = <
|
||||
item
|
||||
Marks.Stripes = csStripes
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Left'
|
||||
Transformations = catLog
|
||||
end
|
||||
item
|
||||
Alignment = calBottom
|
||||
Title.Distance = 0
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Bottom'
|
||||
end
|
||||
item
|
||||
Alignment = calRight
|
||||
Grid.Visible = False
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Right 1'
|
||||
end
|
||||
item
|
||||
Alignment = calTop
|
||||
Inverted = True
|
||||
Title.Caption = 'Top'
|
||||
end>
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Font.Color = clBlue
|
||||
Title.Text.Strings = (
|
||||
'TAChart'
|
||||
)
|
||||
Align = alClient
|
||||
ParentColor = False
|
||||
object clsLogPoints: TLineSeries
|
||||
AxisIndexY = 0
|
||||
LineType = ltNone
|
||||
Pointer.Brush.Color = clMaroon
|
||||
ShowPoints = True
|
||||
end
|
||||
object cfsLog: TFuncSeries
|
||||
Extent.XMin = -1
|
||||
Extent.XMax = 3
|
||||
Extent.UseXMin = True
|
||||
Extent.UseXMax = True
|
||||
AxisIndexY = 0
|
||||
OnCalculate = ChartLogFuncSeries1Calculate
|
||||
end
|
||||
end
|
||||
object pnlLogControls: TPanel
|
||||
Left = 0
|
||||
Height = 29
|
||||
Top = 278
|
||||
Width = 525
|
||||
Align = alBottom
|
||||
ClientHeight = 29
|
||||
ClientWidth = 525
|
||||
TabOrder = 1
|
||||
object cbLog: TCheckBox
|
||||
Left = 4
|
||||
Height = 17
|
||||
Top = 5
|
||||
Width = 64
|
||||
Caption = 'Log scale'
|
||||
Checked = True
|
||||
OnChange = cbLogChange
|
||||
State = cbChecked
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
object tsCustomMarks: TTabSheet
|
||||
Caption = 'Customized marks'
|
||||
ClientHeight = 307
|
||||
@ -216,6 +47,7 @@ object Form1: TForm1
|
||||
Marks.Source = lcsMarks
|
||||
Marks.Style = smsLabel
|
||||
TickLength = 0
|
||||
OnMarkToText = ChartCustomMarksAxisList1MarkToText
|
||||
end>
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
@ -369,54 +201,6 @@ object Form1: TForm1
|
||||
left = 216
|
||||
top = 164
|
||||
end
|
||||
object catLog: TChartAxisTransformations
|
||||
left = 216
|
||||
top = 60
|
||||
object ChartAxisTransformations1LinearAxisTransform2: TLinearAxisTransform
|
||||
Scale = 2
|
||||
end
|
||||
object ChartAxisTransformations1LogarithmAxisTransform1: TLogarithmAxisTransform
|
||||
Base = 10
|
||||
end
|
||||
end
|
||||
object catT: TChartAxisTransformations
|
||||
left = 352
|
||||
top = 60
|
||||
object catTFahrToCel: TLinearAxisTransform
|
||||
Offset = -17.777777777
|
||||
Scale = 0.5555555555
|
||||
end
|
||||
object catTAutoScaleAxisTransform1: TAutoScaleAxisTransform
|
||||
Enabled = False
|
||||
end
|
||||
end
|
||||
object rcsTSummer: TRandomChartSource
|
||||
PointsNumber = 20
|
||||
RandSeed = 114536250
|
||||
XMax = 2009
|
||||
XMin = 1990
|
||||
YMax = 25
|
||||
YMin = 0
|
||||
left = 87
|
||||
top = 106
|
||||
end
|
||||
object rcsTWinter: TRandomChartSource
|
||||
PointsNumber = 20
|
||||
RandSeed = 23453245
|
||||
XMax = 2009
|
||||
XMin = 1990
|
||||
YMax = 20
|
||||
YMin = -15
|
||||
left = 87
|
||||
top = 156
|
||||
end
|
||||
object catTAuto: TChartAxisTransformations
|
||||
left = 352
|
||||
top = 112
|
||||
object catTAutoAutoScaleAxisTransform1: TAutoScaleAxisTransform
|
||||
Enabled = False
|
||||
end
|
||||
end
|
||||
object rcsDates: TRandomChartSource
|
||||
RandSeed = 1079653020
|
||||
XMax = 0
|
||||
|
@ -5,8 +5,8 @@ unit Main;
|
||||
interface
|
||||
|
||||
uses
|
||||
ComCtrls, ExtCtrls, Forms, StdCtrls, TACustomSource, TAFuncSeries, TAGraph,
|
||||
TASeries, TASources, TAStyles, TATools, TATransformations;
|
||||
ComCtrls, ExtCtrls, Forms, TACustomSource, TAFuncSeries, TAGraph,
|
||||
TASeries, TASources, TAStyles, TATools, TATransformations, TAChartAxis;
|
||||
|
||||
type
|
||||
|
||||
@ -15,52 +15,30 @@ type
|
||||
TForm1 = class(TForm)
|
||||
catTAutoAutoScaleAxisTransform1: TAutoScaleAxisTransform;
|
||||
catTAutoScaleAxisTransform1: TAutoScaleAxisTransform;
|
||||
catTAuto: TChartAxisTransformations;
|
||||
cbAuto: TCheckBox;
|
||||
csStripes: TChartStyles;
|
||||
ChartSubmarks: TChart;
|
||||
ChartDateTime: TChart;
|
||||
ChartAxisGroup: TChart;
|
||||
ChartDateTimeLineSeries1: TLineSeries;
|
||||
ChartLog: TChart;
|
||||
cfsLog: TFuncSeries;
|
||||
cbLog: TCheckBox;
|
||||
ChartSubmarksLineSeries1: TLineSeries;
|
||||
ChartToolsetDateTime: TChartToolset;
|
||||
ChartToolset1ZoomIn: TZoomClickTool;
|
||||
ChartToolset1ZoomOut: TZoomClickTool;
|
||||
ChartTWinterBar: TBarSeries;
|
||||
clsLogPoints: TLineSeries;
|
||||
ChartT: TChart;
|
||||
catLog: TChartAxisTransformations;
|
||||
ChartAxisTransformations1LinearAxisTransform2: TLinearAxisTransform;
|
||||
ChartAxisTransformations1LogarithmAxisTransform1: TLogarithmAxisTransform;
|
||||
catT: TChartAxisTransformations;
|
||||
catTFahrToCel: TLinearAxisTransform;
|
||||
ChartCustomMarks: TChart;
|
||||
ChartCustomMarksBarSeries1: TBarSeries;
|
||||
ChartTSummer: TLineSeries;
|
||||
ChartTWinterLine: TLineSeries;
|
||||
DateTimeIntervalChartSource1: TDateTimeIntervalChartSource;
|
||||
lcsMarks: TListChartSource;
|
||||
PageControl1: TPageControl;
|
||||
pnlLogControls: TPanel;
|
||||
pnlAutoControls: TPanel;
|
||||
rcsDates: TRandomChartSource;
|
||||
rcsTSummer: TRandomChartSource;
|
||||
rcsTWinter: TRandomChartSource;
|
||||
lsLinear: TTabSheet;
|
||||
tsSubmarks: TTabSheet;
|
||||
tsDateTime: TTabSheet;
|
||||
tsAxisGroup: TTabSheet;
|
||||
tsLog: TTabSheet;
|
||||
tsCustomMarks: TTabSheet;
|
||||
udcsMain: TUserDefinedChartSource;
|
||||
udcsGraph: TUserDefinedChartSource;
|
||||
udcsSub: TUserDefinedChartSource;
|
||||
procedure cbAutoChange(Sender: TObject);
|
||||
procedure cbLogChange(Sender: TObject);
|
||||
procedure ChartLogFuncSeries1Calculate(const AX: Double; out AY: Double);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure TChartAxisList1MarkToText(var AText: String; AMark: Double);
|
||||
procedure udcsGraphGetChartDataItem(ASource: TUserDefinedChartSource;
|
||||
@ -77,48 +55,21 @@ var
|
||||
implementation
|
||||
|
||||
uses
|
||||
Math, SysUtils, TAChartAxis, TAChartUtils;
|
||||
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);
|
||||
const
|
||||
COLORS: array [1..5] of Integer =
|
||||
($0000A0, $002080, $004060, $006040, $008020);
|
||||
var
|
||||
i, j: Integer;
|
||||
x: Double;
|
||||
ls: TLineSeries;
|
||||
tr: TChartAxisTransformations;
|
||||
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;
|
||||
for i := 1 to 5 do begin
|
||||
ls := TLineSeries.Create(Self);
|
||||
ChartAxisGroup.AddSeries(ls);
|
||||
|
89
components/tachart/demo/axistransf/axistransfdemo.lpi
Normal file
89
components/tachart/demo/axistransf/axistransfdemo.lpi
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveClosedFiles Value="False"/>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="TAChart axis demo"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="TAChartLazarusPkg"/>
|
||||
<MinVersion Major="1" Valid="True"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="axistransfdemo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="axistransfdemo"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Main"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<WriteFPCLogo Value="False"/>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
18
components/tachart/demo/axistransf/axistransfdemo.lpr
Normal file
18
components/tachart/demo/axistransf/axistransfdemo.lpr
Normal file
@ -0,0 +1,18 @@
|
||||
program axistransfdemo;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, Main, TAChartLazarusPkg;
|
||||
|
||||
begin
|
||||
Application.Title := 'TAChart axis transformation demo';
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
253
components/tachart/demo/axistransf/main.lfm
Normal file
253
components/tachart/demo/axistransf/main.lfm
Normal file
@ -0,0 +1,253 @@
|
||||
object Form1: TForm1
|
||||
Left = 343
|
||||
Height = 333
|
||||
Top = 184
|
||||
Width = 533
|
||||
Caption = 'TAChart axis transformation demo'
|
||||
ClientHeight = 333
|
||||
ClientWidth = 533
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.31'
|
||||
object PageControl1: TPageControl
|
||||
Left = 0
|
||||
Height = 333
|
||||
Top = 0
|
||||
Width = 533
|
||||
ActivePage = lsLinear
|
||||
Align = alClient
|
||||
TabIndex = 0
|
||||
TabOrder = 0
|
||||
object lsLinear: TTabSheet
|
||||
Caption = 'Linear'
|
||||
ClientHeight = 307
|
||||
ClientWidth = 525
|
||||
object ChartT: TChart
|
||||
Left = 0
|
||||
Height = 278
|
||||
Top = 0
|
||||
Width = 525
|
||||
AxisList = <
|
||||
item
|
||||
Grid.Visible = False
|
||||
Marks.LabelFont.Color = clRed
|
||||
Marks.AtDataOnly = True
|
||||
TickColor = clRed
|
||||
Title.LabelFont.Color = clRed
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Summer temperature, °C'
|
||||
Transformations = catTAuto
|
||||
end
|
||||
item
|
||||
Alignment = calBottom
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Year'
|
||||
end
|
||||
item
|
||||
Alignment = calRight
|
||||
Grid.Visible = False
|
||||
Marks.Distance = 4
|
||||
Marks.LabelFont.Color = clBlue
|
||||
Marks.AtDataOnly = True
|
||||
TickColor = clBlue
|
||||
Title.LabelFont.Color = clBlue
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Winter temperature, °F'
|
||||
Transformations = catT
|
||||
end>
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Frame.Visible = False
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Font.Color = clBlue
|
||||
Title.Text.Strings = (
|
||||
'TAChart'
|
||||
)
|
||||
Align = alClient
|
||||
ParentColor = False
|
||||
object ChartTSummer: TLineSeries
|
||||
AxisIndexY = 0
|
||||
LinePen.Color = clRed
|
||||
LinePen.Width = 2
|
||||
Source = rcsTSummer
|
||||
end
|
||||
object ChartTWinterLine: TLineSeries
|
||||
AxisIndexY = 2
|
||||
LinePen.Color = clBlue
|
||||
LinePen.Width = 2
|
||||
Source = rcsTWinter
|
||||
end
|
||||
object ChartTWinterBar: TBarSeries
|
||||
AxisIndexY = 2
|
||||
BarBrush.Color = clBlue
|
||||
BarBrush.Style = bsDiagCross
|
||||
Source = rcsTWinter
|
||||
end
|
||||
end
|
||||
object pnlAutoControls: TPanel
|
||||
Left = 0
|
||||
Height = 29
|
||||
Top = 278
|
||||
Width = 525
|
||||
Align = alBottom
|
||||
ClientHeight = 29
|
||||
ClientWidth = 525
|
||||
TabOrder = 1
|
||||
object cbAuto: TCheckBox
|
||||
Left = 4
|
||||
Height = 17
|
||||
Top = 5
|
||||
Width = 70
|
||||
Caption = 'Auto scale'
|
||||
OnChange = cbAutoChange
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
object tsLog: TTabSheet
|
||||
Caption = 'Logarithm'
|
||||
ClientHeight = 307
|
||||
ClientWidth = 525
|
||||
object ChartLog: TChart
|
||||
Left = 0
|
||||
Height = 278
|
||||
Top = 0
|
||||
Width = 525
|
||||
AxisList = <
|
||||
item
|
||||
Marks.Stripes = csStripes
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Left'
|
||||
Transformations = catLog
|
||||
end
|
||||
item
|
||||
Alignment = calBottom
|
||||
Title.Distance = 0
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Bottom'
|
||||
end
|
||||
item
|
||||
Alignment = calRight
|
||||
Grid.Visible = False
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Right 1'
|
||||
end
|
||||
item
|
||||
Alignment = calTop
|
||||
Inverted = True
|
||||
Title.Caption = 'Top'
|
||||
end>
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Font.Color = clBlue
|
||||
Title.Text.Strings = (
|
||||
'TAChart'
|
||||
)
|
||||
Align = alClient
|
||||
ParentColor = False
|
||||
object clsLogPoints: TLineSeries
|
||||
AxisIndexY = 0
|
||||
LineType = ltNone
|
||||
Pointer.Brush.Color = clMaroon
|
||||
ShowPoints = True
|
||||
end
|
||||
object cfsLog: TFuncSeries
|
||||
Active = False
|
||||
Extent.XMin = -1
|
||||
Extent.XMax = 3
|
||||
Extent.UseXMin = True
|
||||
Extent.UseXMax = True
|
||||
AxisIndexY = 0
|
||||
OnCalculate = ChartLogFuncSeries1Calculate
|
||||
end
|
||||
end
|
||||
object pnlLogControls: TPanel
|
||||
Left = 0
|
||||
Height = 29
|
||||
Top = 278
|
||||
Width = 525
|
||||
Align = alBottom
|
||||
ClientHeight = 29
|
||||
ClientWidth = 525
|
||||
TabOrder = 1
|
||||
object cbLog: TCheckBox
|
||||
Left = 4
|
||||
Height = 17
|
||||
Top = 5
|
||||
Width = 64
|
||||
Caption = 'Log scale'
|
||||
Checked = True
|
||||
OnChange = cbLogChange
|
||||
State = cbChecked
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
object catLog: TChartAxisTransformations
|
||||
left = 216
|
||||
top = 60
|
||||
object ChartAxisTransformations1LinearAxisTransform2: TLinearAxisTransform
|
||||
Scale = 2
|
||||
end
|
||||
object ChartAxisTransformations1LogarithmAxisTransform1: TLogarithmAxisTransform
|
||||
Base = 10
|
||||
end
|
||||
end
|
||||
object catT: TChartAxisTransformations
|
||||
left = 352
|
||||
top = 60
|
||||
object catTFahrToCel: TLinearAxisTransform
|
||||
Offset = -17.777777777
|
||||
Scale = 0.5555555555
|
||||
end
|
||||
object catTAutoScaleAxisTransform1: TAutoScaleAxisTransform
|
||||
Enabled = False
|
||||
end
|
||||
end
|
||||
object rcsTSummer: TRandomChartSource
|
||||
PointsNumber = 20
|
||||
RandSeed = 114536250
|
||||
XMax = 2009
|
||||
XMin = 1990
|
||||
YMax = 25
|
||||
YMin = 0
|
||||
left = 87
|
||||
top = 106
|
||||
end
|
||||
object rcsTWinter: TRandomChartSource
|
||||
PointsNumber = 20
|
||||
RandSeed = 23453245
|
||||
XMax = 2009
|
||||
XMin = 1990
|
||||
YMax = 20
|
||||
YMin = -15
|
||||
left = 87
|
||||
top = 156
|
||||
end
|
||||
object catTAuto: TChartAxisTransformations
|
||||
left = 352
|
||||
top = 112
|
||||
object catTAutoAutoScaleAxisTransform1: TAutoScaleAxisTransform
|
||||
Enabled = False
|
||||
end
|
||||
end
|
||||
object csStripes: TChartStyles
|
||||
Styles = <
|
||||
item
|
||||
Brush.Color = 16631498
|
||||
UsePen = False
|
||||
end
|
||||
item
|
||||
Brush.Color = 12319483
|
||||
UsePen = False
|
||||
end>
|
||||
left = 352
|
||||
top = 176
|
||||
end
|
||||
end
|
93
components/tachart/demo/axistransf/main.pas
Normal file
93
components/tachart/demo/axistransf/main.pas
Normal file
@ -0,0 +1,93 @@
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user