mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:59:20 +02:00
TAChart: Use TCumulNormDistrAxisTransform in the axis transform demo. Based on code by Werner Pamler.
git-svn-id: trunk@32693 -
This commit is contained in:
parent
6e376ce0a8
commit
e3733ed9ff
@ -75,6 +75,10 @@
|
|||||||
<SmartLinkUnit Value="True"/>
|
<SmartLinkUnit Value="True"/>
|
||||||
</CodeGeneration>
|
</CodeGeneration>
|
||||||
<Linking>
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="True"/>
|
||||||
|
<DebugInfoType Value="dsAuto"/>
|
||||||
|
</Debugging>
|
||||||
<LinkSmart Value="True"/>
|
<LinkSmart Value="True"/>
|
||||||
<Options>
|
<Options>
|
||||||
<Win32>
|
<Win32>
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 1345
|
Left = 1345
|
||||||
Height = 333
|
Height = 434
|
||||||
Top = 166
|
Top = 166
|
||||||
Width = 533
|
Width = 533
|
||||||
Caption = 'TAChart axis transformation demo'
|
Caption = 'TAChart axis transformation demo'
|
||||||
ClientHeight = 333
|
ClientHeight = 434
|
||||||
ClientWidth = 533
|
ClientWidth = 533
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '0.9.31'
|
LCLVersion = '0.9.31'
|
||||||
object PageControl1: TPageControl
|
object PageControl1: TPageControl
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 333
|
Height = 434
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 533
|
Width = 533
|
||||||
ActivePage = lsLinear
|
ActivePage = tsLinear
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabIndex = 0
|
TabIndex = 0
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object lsLinear: TTabSheet
|
object tsLinear: TTabSheet
|
||||||
Caption = 'Linear'
|
Caption = 'Linear'
|
||||||
ClientHeight = 307
|
ClientHeight = 408
|
||||||
ClientWidth = 525
|
ClientWidth = 525
|
||||||
object ChartT: TChart
|
object ChartT: TChart
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 278
|
Height = 379
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 525
|
Width = 525
|
||||||
AxisList = <
|
AxisList = <
|
||||||
@ -94,7 +94,7 @@ object Form1: TForm1
|
|||||||
object pnlAutoControls: TPanel
|
object pnlAutoControls: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 29
|
Height = 29
|
||||||
Top = 278
|
Top = 379
|
||||||
Width = 525
|
Width = 525
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
ClientHeight = 29
|
ClientHeight = 29
|
||||||
@ -113,11 +113,11 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object tsIndependent: TTabSheet
|
object tsIndependent: TTabSheet
|
||||||
Caption = 'Independent scale'
|
Caption = 'Independent scale'
|
||||||
ClientHeight = 307
|
ClientHeight = 408
|
||||||
ClientWidth = 525
|
ClientWidth = 525
|
||||||
object ChartIndependent: TChart
|
object ChartIndependent: TChart
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 269
|
Height = 370
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 525
|
Width = 525
|
||||||
AxisList = <
|
AxisList = <
|
||||||
@ -164,7 +164,7 @@ object Form1: TForm1
|
|||||||
object pnlIndependentControls: TPanel
|
object pnlIndependentControls: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 38
|
Height = 38
|
||||||
Top = 269
|
Top = 370
|
||||||
Width = 525
|
Width = 525
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
ClientHeight = 38
|
ClientHeight = 38
|
||||||
@ -220,11 +220,11 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object tsLog: TTabSheet
|
object tsLog: TTabSheet
|
||||||
Caption = 'Logarithm'
|
Caption = 'Logarithm'
|
||||||
ClientHeight = 307
|
ClientHeight = 408
|
||||||
ClientWidth = 525
|
ClientWidth = 525
|
||||||
object ChartLog: TChart
|
object ChartLog: TChart
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 278
|
Height = 379
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 525
|
Width = 525
|
||||||
AxisList = <
|
AxisList = <
|
||||||
@ -238,6 +238,7 @@ object Form1: TForm1
|
|||||||
item
|
item
|
||||||
Grid.Visible = False
|
Grid.Visible = False
|
||||||
Intervals.Count = 9
|
Intervals.Count = 9
|
||||||
|
Intervals.MinLength = 5
|
||||||
Intervals.Options = [aipUseCount, aipUseMaxLength, aipUseMinLength, aipUseNiceSteps]
|
Intervals.Options = [aipUseCount, aipUseMaxLength, aipUseMinLength, aipUseNiceSteps]
|
||||||
end>
|
end>
|
||||||
Title.LabelFont.Orientation = 900
|
Title.LabelFont.Orientation = 900
|
||||||
@ -284,7 +285,6 @@ object Form1: TForm1
|
|||||||
ShowPoints = True
|
ShowPoints = True
|
||||||
end
|
end
|
||||||
object cfsLog: TFuncSeries
|
object cfsLog: TFuncSeries
|
||||||
Active = False
|
|
||||||
Extent.UseXMax = True
|
Extent.UseXMax = True
|
||||||
Extent.UseXMin = True
|
Extent.UseXMin = True
|
||||||
Extent.XMax = 3
|
Extent.XMax = 3
|
||||||
@ -296,7 +296,7 @@ object Form1: TForm1
|
|||||||
object pnlLogControls: TPanel
|
object pnlLogControls: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 29
|
Height = 29
|
||||||
Top = 278
|
Top = 379
|
||||||
Width = 525
|
Width = 525
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
ClientHeight = 29
|
ClientHeight = 29
|
||||||
@ -315,13 +315,149 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object tsCumulNormDistr: TTabSheet
|
||||||
|
Caption = 'Normal distribution'
|
||||||
|
ClientHeight = 408
|
||||||
|
ClientWidth = 525
|
||||||
|
object ChartCumulNormDistr: TChart
|
||||||
|
Left = 0
|
||||||
|
Height = 342
|
||||||
|
Top = 66
|
||||||
|
Width = 525
|
||||||
|
AxisList = <
|
||||||
|
item
|
||||||
|
Grid.Color = clSilver
|
||||||
|
Grid.Visible = False
|
||||||
|
Intervals.Count = 30
|
||||||
|
Intervals.Options = [aipUseCount, aipUseNiceSteps]
|
||||||
|
Marks.OverlapPolicy = opHideNeighbour
|
||||||
|
Minors = <>
|
||||||
|
Title.LabelFont.Orientation = 900
|
||||||
|
Title.LabelFont.Style = [fsBold]
|
||||||
|
Title.Visible = True
|
||||||
|
Title.Caption = 'Cumulative probability'
|
||||||
|
Transformations = catCumulNormDistr
|
||||||
|
end
|
||||||
|
item
|
||||||
|
Grid.Color = clSilver
|
||||||
|
Grid.Visible = False
|
||||||
|
Alignment = calBottom
|
||||||
|
Minors = <>
|
||||||
|
Title.LabelFont.Style = [fsBold]
|
||||||
|
Title.Visible = True
|
||||||
|
Title.Caption = 'Random number'
|
||||||
|
end>
|
||||||
|
BackColor = clWhite
|
||||||
|
Extent.XMax = 3
|
||||||
|
Extent.XMin = -3
|
||||||
|
Extent.YMax = 3
|
||||||
|
Extent.YMin = -3
|
||||||
|
Foot.Brush.Color = clBtnFace
|
||||||
|
Foot.Font.Color = clBlue
|
||||||
|
MarginsExternal.Left = 8
|
||||||
|
MarginsExternal.Right = 12
|
||||||
|
MarginsExternal.Bottom = 8
|
||||||
|
Title.Brush.Color = clBtnFace
|
||||||
|
Title.Font.Color = clBlue
|
||||||
|
Title.Text.Strings = (
|
||||||
|
'TAChart'
|
||||||
|
)
|
||||||
|
Align = alClient
|
||||||
|
ParentColor = False
|
||||||
|
object ChartCumulNormDistrLineSeries1: TLineSeries
|
||||||
|
AxisIndexX = 1
|
||||||
|
AxisIndexY = 0
|
||||||
|
Pointer.Brush.Color = clBlue
|
||||||
|
Pointer.HorizSize = 2
|
||||||
|
Pointer.Pen.Color = clBlue
|
||||||
|
Pointer.Style = psCircle
|
||||||
|
Pointer.VertSize = 2
|
||||||
|
ShowPoints = True
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object pnCumulNormDistr: TPanel
|
||||||
|
Left = 0
|
||||||
|
Height = 66
|
||||||
|
Top = 0
|
||||||
|
Width = 525
|
||||||
|
Align = alTop
|
||||||
|
BevelOuter = bvNone
|
||||||
|
ClientHeight = 66
|
||||||
|
ClientWidth = 525
|
||||||
|
TabOrder = 1
|
||||||
|
object rgRandDistr: TRadioGroup
|
||||||
|
Left = 0
|
||||||
|
Height = 66
|
||||||
|
Top = 0
|
||||||
|
Width = 185
|
||||||
|
Align = alLeft
|
||||||
|
AutoFill = True
|
||||||
|
Caption = ' Random number generation '
|
||||||
|
ChildSizing.LeftRightSpacing = 6
|
||||||
|
ChildSizing.TopBottomSpacing = 6
|
||||||
|
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||||
|
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||||
|
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||||
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
|
ChildSizing.ControlsPerLine = 1
|
||||||
|
ClientHeight = 48
|
||||||
|
ClientWidth = 181
|
||||||
|
ItemIndex = 1
|
||||||
|
Items.Strings = (
|
||||||
|
'uniform distribution'
|
||||||
|
'normal distribution'
|
||||||
|
)
|
||||||
|
OnClick = rgRandDistrClick
|
||||||
|
ParentFont = False
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object cbPercent: TCheckBox
|
||||||
|
Left = 192
|
||||||
|
Height = 17
|
||||||
|
Top = 43
|
||||||
|
Width = 57
|
||||||
|
Caption = 'Percent'
|
||||||
|
OnChange = cbPercentChange
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object cbUseAxisTransform: TCheckBox
|
||||||
|
Left = 280
|
||||||
|
Height = 17
|
||||||
|
Top = 43
|
||||||
|
Width = 110
|
||||||
|
Caption = 'Use AxisTransform'
|
||||||
|
OnChange = cbUseAxisTransformChange
|
||||||
|
TabOrder = 2
|
||||||
|
end
|
||||||
|
object edDataCount: TSpinEdit
|
||||||
|
Left = 281
|
||||||
|
Height = 21
|
||||||
|
Top = 10
|
||||||
|
Width = 82
|
||||||
|
Increment = 50
|
||||||
|
MaxValue = 1000000
|
||||||
|
OnChange = edDataCountChange
|
||||||
|
TabOrder = 3
|
||||||
|
Value = 300
|
||||||
|
end
|
||||||
|
object lblDataCount: TLabel
|
||||||
|
Left = 194
|
||||||
|
Height = 14
|
||||||
|
Top = 14
|
||||||
|
Width = 58
|
||||||
|
Caption = 'Data count:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
object tsUser: TTabSheet
|
object tsUser: TTabSheet
|
||||||
Caption = 'User defined'
|
Caption = 'User defined'
|
||||||
ClientHeight = 307
|
ClientHeight = 408
|
||||||
ClientWidth = 525
|
ClientWidth = 525
|
||||||
object ChartUser: TChart
|
object ChartUser: TChart
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 307
|
Height = 408
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 525
|
Width = 525
|
||||||
AxisList = <
|
AxisList = <
|
||||||
@ -462,4 +598,19 @@ object Form1: TForm1
|
|||||||
object catIndependent2Zoom: TLinearAxisTransform
|
object catIndependent2Zoom: TLinearAxisTransform
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object AxLabelSource: TListChartSource
|
||||||
|
left = 311
|
||||||
|
top = 305
|
||||||
|
end
|
||||||
|
object catCumulNormDistr: TChartAxisTransformations
|
||||||
|
left = 310
|
||||||
|
top = 305
|
||||||
|
object catCumulNormDistrLinearAxisTransform1: TLinearAxisTransform
|
||||||
|
Enabled = False
|
||||||
|
Scale = 0.01
|
||||||
|
end
|
||||||
|
object catCumulNormDistrCumulNormDistrAxisTransform1: TCumulNormDistrAxisTransform
|
||||||
|
Enabled = False
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,6 +13,9 @@ type
|
|||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
|
AxLabelSource: TListChartSource;
|
||||||
|
catCumulNormDistrCumulNormDistrAxisTransform1: TCumulNormDistrAxisTransform;
|
||||||
|
catCumulNormDistrLinearAxisTransform1: TLinearAxisTransform;
|
||||||
catIndependent1Zoom: TLinearAxisTransform;
|
catIndependent1Zoom: TLinearAxisTransform;
|
||||||
catIndependent2Zoom: TLinearAxisTransform;
|
catIndependent2Zoom: TLinearAxisTransform;
|
||||||
catIndependent2: TChartAxisTransformations;
|
catIndependent2: TChartAxisTransformations;
|
||||||
@ -23,9 +26,14 @@ type
|
|||||||
catUser: TChartAxisTransformations;
|
catUser: TChartAxisTransformations;
|
||||||
catUserUserDefinedAxisTransform1: TUserDefinedAxisTransform;
|
catUserUserDefinedAxisTransform1: TUserDefinedAxisTransform;
|
||||||
catIndependent1: TChartAxisTransformations;
|
catIndependent1: TChartAxisTransformations;
|
||||||
|
cbPercent: TCheckBox;
|
||||||
|
cbUseAxisTransform: TCheckBox;
|
||||||
|
ChartCumulNormDistr: TChart;
|
||||||
|
catCumulNormDistr: TChartAxisTransformations;
|
||||||
ChartIndependent: TChart;
|
ChartIndependent: TChart;
|
||||||
ChartIndependentLineSeries1: TLineSeries;
|
ChartIndependentLineSeries1: TLineSeries;
|
||||||
ChartIndependentLineSeries2: TLineSeries;
|
ChartIndependentLineSeries2: TLineSeries;
|
||||||
|
ChartCumulNormDistrLineSeries1: TLineSeries;
|
||||||
ChartToolset1: TChartToolset;
|
ChartToolset1: TChartToolset;
|
||||||
ChartToolset1DataPointDragTool1: TDataPointDragTool;
|
ChartToolset1DataPointDragTool1: TDataPointDragTool;
|
||||||
ChartUser: TChart;
|
ChartUser: TChart;
|
||||||
@ -45,18 +53,23 @@ type
|
|||||||
catTFahrToCel: TLinearAxisTransform;
|
catTFahrToCel: TLinearAxisTransform;
|
||||||
ChartTSummer: TLineSeries;
|
ChartTSummer: TLineSeries;
|
||||||
ChartTWinterLine: TLineSeries;
|
ChartTWinterLine: TLineSeries;
|
||||||
|
edDataCount: TSpinEdit;
|
||||||
fseIndependent1: TFloatSpinEdit;
|
fseIndependent1: TFloatSpinEdit;
|
||||||
fseIndependent2: TFloatSpinEdit;
|
fseIndependent2: TFloatSpinEdit;
|
||||||
|
lblDataCount: TLabel;
|
||||||
lblIndependentScale1: TLabel;
|
lblIndependentScale1: TLabel;
|
||||||
lblIndependentScale2: TLabel;
|
lblIndependentScale2: TLabel;
|
||||||
PageControl1: TPageControl;
|
PageControl1: TPageControl;
|
||||||
|
pnCumulNormDistr: TPanel;
|
||||||
pnlIndependentControls: TPanel;
|
pnlIndependentControls: TPanel;
|
||||||
pnlLogControls: TPanel;
|
pnlLogControls: TPanel;
|
||||||
pnlAutoControls: TPanel;
|
pnlAutoControls: TPanel;
|
||||||
rcsUser: TRandomChartSource;
|
rcsUser: TRandomChartSource;
|
||||||
rcsTSummer: TRandomChartSource;
|
rcsTSummer: TRandomChartSource;
|
||||||
rcsTWinter: TRandomChartSource;
|
rcsTWinter: TRandomChartSource;
|
||||||
lsLinear: TTabSheet;
|
rgRandDistr: TRadioGroup;
|
||||||
|
tsLinear: TTabSheet;
|
||||||
|
tsCumulNormDistr: TTabSheet;
|
||||||
tsIndependent: TTabSheet;
|
tsIndependent: TTabSheet;
|
||||||
tsUser: TTabSheet;
|
tsUser: TTabSheet;
|
||||||
tsLog: TTabSheet;
|
tsLog: TTabSheet;
|
||||||
@ -64,12 +77,17 @@ type
|
|||||||
procedure cbLogChange(Sender: TObject);
|
procedure cbLogChange(Sender: TObject);
|
||||||
procedure catUserUserDefinedAxisTransform1AxisToGraph(
|
procedure catUserUserDefinedAxisTransform1AxisToGraph(
|
||||||
AX: Double; out AT: Double);
|
AX: Double; out AT: Double);
|
||||||
|
procedure cbPercentChange(Sender: TObject);
|
||||||
|
procedure cbUseAxisTransformChange(Sender: TObject);
|
||||||
procedure ChartLogFuncSeries1Calculate(const AX: Double; out AY: Double);
|
procedure ChartLogFuncSeries1Calculate(const AX: Double; out AY: Double);
|
||||||
|
procedure edDataCountChange(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure fseIndependent1Change(Sender: TObject);
|
procedure fseIndependent1Change(Sender: TObject);
|
||||||
procedure fseIndependent2Change(Sender: TObject);
|
procedure fseIndependent2Change(Sender: TObject);
|
||||||
|
procedure rgRandDistrClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
procedure FillIndependentSource;
|
procedure FillIndependentSource;
|
||||||
|
procedure FillCumulNormDistrSource;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -78,10 +96,35 @@ var
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math, SysUtils, TAChartAxis, TAChartUtils;
|
Math, StrUtils, SysUtils, TAChartAxis, TAChartUtils;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
|
var
|
||||||
|
GaussDevAvail: Boolean = false;
|
||||||
|
GaussDev: Double = 0.0;
|
||||||
|
|
||||||
|
// Create a random number with normal distribution, mean value 0, standard
|
||||||
|
// deviation 1. See Numerical Recipes.
|
||||||
|
function RndNormal: Double;
|
||||||
|
var
|
||||||
|
fac, r, v1, v2: Double;
|
||||||
|
begin
|
||||||
|
if GaussDevAvail then
|
||||||
|
Result := GaussDev
|
||||||
|
else begin
|
||||||
|
repeat
|
||||||
|
v1 := 2.0 * Random - 1.0;
|
||||||
|
v2 := 2.0 * Random - 1.0;
|
||||||
|
r := Sqr(v1) + Sqr(v2);
|
||||||
|
until (r > 0.0) and (r < 1.0);
|
||||||
|
fac := Sqrt(-2.0 * Ln(r) / r);
|
||||||
|
GaussDev := v1 * fac;
|
||||||
|
Result := v2 * fac;
|
||||||
|
end;
|
||||||
|
GaussDevAvail := not GaussDevAvail;
|
||||||
|
end;
|
||||||
|
|
||||||
function MyFunc(AX: Double): Double;
|
function MyFunc(AX: Double): Double;
|
||||||
begin
|
begin
|
||||||
Result := Power(10, AX) + 3;
|
Result := Power(10, AX) + 3;
|
||||||
@ -100,6 +143,20 @@ begin
|
|||||||
ChartAxisTransformations1LogarithmAxisTransform1.Enabled := cbLog.Checked;
|
ChartAxisTransformations1LogarithmAxisTransform1.Enabled := cbLog.Checked;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.cbPercentChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
catCumulNormDistrLinearAxisTransform1.Enabled := cbPercent.Checked;
|
||||||
|
FillCumulNormDistrSource;
|
||||||
|
ChartCumulNormDistr.LeftAxis.Title.Caption :=
|
||||||
|
'Cumulative probability' + IfThen(cbPercent.Checked, ' (%)', '');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.cbUseAxisTransformChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
catCumulNormDistrCumulNormDistrAxisTransform1.Enabled :=
|
||||||
|
cbUseAxisTransform.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.catUserUserDefinedAxisTransform1AxisToGraph(
|
procedure TForm1.catUserUserDefinedAxisTransform1AxisToGraph(
|
||||||
AX: Double; out AT: Double);
|
AX: Double; out AT: Double);
|
||||||
const
|
const
|
||||||
@ -121,6 +178,41 @@ begin
|
|||||||
AY := MyFunc(AX);
|
AY := MyFunc(AX);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.edDataCountChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FillCumulNormDistrSource;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.FillCumulNormDistrSource;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
y: Double;
|
||||||
|
s: TListChartSource;
|
||||||
|
begin
|
||||||
|
RandSeed := 976896;
|
||||||
|
s := ChartCumulNormDistrLineSeries1.ListSource;
|
||||||
|
s.BeginUpdate;
|
||||||
|
try
|
||||||
|
s.Clear;
|
||||||
|
// Add random test data as x values --> random values will
|
||||||
|
// get sorted in ascending direction automatically.
|
||||||
|
s.Sorted := false;
|
||||||
|
for i := 1 to edDataCount.Value do
|
||||||
|
case rgRandDistr.ItemIndex of
|
||||||
|
0: s.Add(Random, 0);
|
||||||
|
1: s.Add(RndNormal, 0);
|
||||||
|
end;
|
||||||
|
s.Sorted := true;
|
||||||
|
// Calculate cumulative probability from index in sorted list.
|
||||||
|
for i := 0 to s.Count - 1 do begin
|
||||||
|
y := (i + 1) / (s.Count + 1); // Add 1 since y=0 and y=1 are not valid.
|
||||||
|
s.Item[i]^.Y := IfThen(CbPercent.Checked, y * 100, y);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
s.EndUpdate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.FillIndependentSource;
|
procedure TForm1.FillIndependentSource;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -149,6 +241,7 @@ begin
|
|||||||
clsLogPoints.AddXY(x + Random - 0.5, MyFunc(x) + Random - 0.5);
|
clsLogPoints.AddXY(x + Random - 0.5, MyFunc(x) + Random - 0.5);
|
||||||
end;
|
end;
|
||||||
FillIndependentSource;
|
FillIndependentSource;
|
||||||
|
FillCumulNormDistrSource;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.fseIndependent1Change(Sender: TObject);
|
procedure TForm1.fseIndependent1Change(Sender: TObject);
|
||||||
@ -161,5 +254,10 @@ begin
|
|||||||
catIndependent2Zoom.Scale := fseIndependent2.Value;
|
catIndependent2Zoom.Scale := fseIndependent2.Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.rgRandDistrClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FillCumulNormDistrSource;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user