mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:19:22 +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/axisdemo.lpr svneol=native#text/pascal
|
||||||
components/tachart/demo/axis/main.lfm svneol=native#text/plain
|
components/tachart/demo/axis/main.lfm svneol=native#text/plain
|
||||||
components/tachart/demo/axis/main.pas svneol=native#text/pascal
|
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.lpi svneol=native#text/plain
|
||||||
components/tachart/demo/basic/demo.lpr svneol=native#text/plain
|
components/tachart/demo/basic/demo.lpr svneol=native#text/plain
|
||||||
components/tachart/demo/basic/unit1.lfm svneol=native#text/plain
|
components/tachart/demo/basic/unit1.lfm svneol=native#text/plain
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="9"/>
|
<Version Value="10"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
@ -14,179 +14,10 @@ object Form1: TForm1
|
|||||||
Height = 333
|
Height = 333
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 533
|
Width = 533
|
||||||
ActivePage = lsLinear
|
ActivePage = tsCustomMarks
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabIndex = 0
|
TabIndex = 0
|
||||||
TabOrder = 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
|
object tsCustomMarks: TTabSheet
|
||||||
Caption = 'Customized marks'
|
Caption = 'Customized marks'
|
||||||
ClientHeight = 307
|
ClientHeight = 307
|
||||||
@ -216,6 +47,7 @@ object Form1: TForm1
|
|||||||
Marks.Source = lcsMarks
|
Marks.Source = lcsMarks
|
||||||
Marks.Style = smsLabel
|
Marks.Style = smsLabel
|
||||||
TickLength = 0
|
TickLength = 0
|
||||||
|
OnMarkToText = ChartCustomMarksAxisList1MarkToText
|
||||||
end>
|
end>
|
||||||
Foot.Brush.Color = clBtnFace
|
Foot.Brush.Color = clBtnFace
|
||||||
Foot.Font.Color = clBlue
|
Foot.Font.Color = clBlue
|
||||||
@ -369,54 +201,6 @@ object Form1: TForm1
|
|||||||
left = 216
|
left = 216
|
||||||
top = 164
|
top = 164
|
||||||
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 rcsDates: TRandomChartSource
|
object rcsDates: TRandomChartSource
|
||||||
RandSeed = 1079653020
|
RandSeed = 1079653020
|
||||||
XMax = 0
|
XMax = 0
|
||||||
|
@ -5,8 +5,8 @@ unit Main;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
ComCtrls, ExtCtrls, Forms, StdCtrls, TACustomSource, TAFuncSeries, TAGraph,
|
ComCtrls, ExtCtrls, Forms, TACustomSource, TAFuncSeries, TAGraph,
|
||||||
TASeries, TASources, TAStyles, TATools, TATransformations;
|
TASeries, TASources, TAStyles, TATools, TATransformations, TAChartAxis;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -15,52 +15,30 @@ type
|
|||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
catTAutoAutoScaleAxisTransform1: TAutoScaleAxisTransform;
|
catTAutoAutoScaleAxisTransform1: TAutoScaleAxisTransform;
|
||||||
catTAutoScaleAxisTransform1: TAutoScaleAxisTransform;
|
catTAutoScaleAxisTransform1: TAutoScaleAxisTransform;
|
||||||
catTAuto: TChartAxisTransformations;
|
|
||||||
cbAuto: TCheckBox;
|
|
||||||
csStripes: TChartStyles;
|
csStripes: TChartStyles;
|
||||||
ChartSubmarks: TChart;
|
ChartSubmarks: TChart;
|
||||||
ChartDateTime: TChart;
|
ChartDateTime: TChart;
|
||||||
ChartAxisGroup: TChart;
|
ChartAxisGroup: TChart;
|
||||||
ChartDateTimeLineSeries1: TLineSeries;
|
ChartDateTimeLineSeries1: TLineSeries;
|
||||||
ChartLog: TChart;
|
|
||||||
cfsLog: TFuncSeries;
|
|
||||||
cbLog: TCheckBox;
|
|
||||||
ChartSubmarksLineSeries1: TLineSeries;
|
ChartSubmarksLineSeries1: TLineSeries;
|
||||||
ChartToolsetDateTime: TChartToolset;
|
ChartToolsetDateTime: TChartToolset;
|
||||||
ChartToolset1ZoomIn: TZoomClickTool;
|
ChartToolset1ZoomIn: TZoomClickTool;
|
||||||
ChartToolset1ZoomOut: TZoomClickTool;
|
ChartToolset1ZoomOut: TZoomClickTool;
|
||||||
ChartTWinterBar: TBarSeries;
|
|
||||||
clsLogPoints: TLineSeries;
|
|
||||||
ChartT: TChart;
|
|
||||||
catLog: TChartAxisTransformations;
|
|
||||||
ChartAxisTransformations1LinearAxisTransform2: TLinearAxisTransform;
|
|
||||||
ChartAxisTransformations1LogarithmAxisTransform1: TLogarithmAxisTransform;
|
|
||||||
catT: TChartAxisTransformations;
|
catT: TChartAxisTransformations;
|
||||||
catTFahrToCel: TLinearAxisTransform;
|
catTFahrToCel: TLinearAxisTransform;
|
||||||
ChartCustomMarks: TChart;
|
ChartCustomMarks: TChart;
|
||||||
ChartCustomMarksBarSeries1: TBarSeries;
|
ChartCustomMarksBarSeries1: TBarSeries;
|
||||||
ChartTSummer: TLineSeries;
|
|
||||||
ChartTWinterLine: TLineSeries;
|
|
||||||
DateTimeIntervalChartSource1: TDateTimeIntervalChartSource;
|
DateTimeIntervalChartSource1: TDateTimeIntervalChartSource;
|
||||||
lcsMarks: TListChartSource;
|
lcsMarks: TListChartSource;
|
||||||
PageControl1: TPageControl;
|
PageControl1: TPageControl;
|
||||||
pnlLogControls: TPanel;
|
|
||||||
pnlAutoControls: TPanel;
|
|
||||||
rcsDates: TRandomChartSource;
|
rcsDates: TRandomChartSource;
|
||||||
rcsTSummer: TRandomChartSource;
|
|
||||||
rcsTWinter: TRandomChartSource;
|
|
||||||
lsLinear: TTabSheet;
|
|
||||||
tsSubmarks: TTabSheet;
|
tsSubmarks: TTabSheet;
|
||||||
tsDateTime: TTabSheet;
|
tsDateTime: TTabSheet;
|
||||||
tsAxisGroup: TTabSheet;
|
tsAxisGroup: TTabSheet;
|
||||||
tsLog: TTabSheet;
|
|
||||||
tsCustomMarks: TTabSheet;
|
tsCustomMarks: TTabSheet;
|
||||||
udcsMain: TUserDefinedChartSource;
|
udcsMain: TUserDefinedChartSource;
|
||||||
udcsGraph: TUserDefinedChartSource;
|
udcsGraph: TUserDefinedChartSource;
|
||||||
udcsSub: TUserDefinedChartSource;
|
udcsSub: TUserDefinedChartSource;
|
||||||
procedure cbAutoChange(Sender: TObject);
|
|
||||||
procedure cbLogChange(Sender: TObject);
|
|
||||||
procedure ChartLogFuncSeries1Calculate(const AX: Double; out AY: Double);
|
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure TChartAxisList1MarkToText(var AText: String; AMark: Double);
|
procedure TChartAxisList1MarkToText(var AText: String; AMark: Double);
|
||||||
procedure udcsGraphGetChartDataItem(ASource: TUserDefinedChartSource;
|
procedure udcsGraphGetChartDataItem(ASource: TUserDefinedChartSource;
|
||||||
@ -77,48 +55,21 @@ var
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math, SysUtils, TAChartAxis, TAChartUtils;
|
SysUtils, TAChartAxis, TAChartUtils;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
function MyFunc(AX: Double): Double;
|
|
||||||
begin
|
|
||||||
Result := Power(10, AX) + 3;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TForm1 }
|
{ 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);
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
const
|
const
|
||||||
COLORS: array [1..5] of Integer =
|
COLORS: array [1..5] of Integer =
|
||||||
($0000A0, $002080, $004060, $006040, $008020);
|
($0000A0, $002080, $004060, $006040, $008020);
|
||||||
var
|
var
|
||||||
i, j: Integer;
|
i, j: Integer;
|
||||||
x: Double;
|
|
||||||
ls: TLineSeries;
|
ls: TLineSeries;
|
||||||
tr: TChartAxisTransformations;
|
tr: TChartAxisTransformations;
|
||||||
begin
|
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
|
for i := 1 to 5 do begin
|
||||||
ls := TLineSeries.Create(Self);
|
ls := TLineSeries.Create(Self);
|
||||||
ChartAxisGroup.AddSeries(ls);
|
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