LazStats: Use TAChart in ABCNestedUnit. Add data file ABCNested.laz from OpenStat demos. Some refactoring. New procedure in Utils: AddComboboxToToolbar.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7864 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-11-12 18:31:56 +00:00
parent 92ac9ce5a8
commit aed12b6bbd
7 changed files with 834 additions and 195 deletions

View File

@ -0,0 +1,305 @@
54
4
A
VARIABLE 1
1
I
0
99999
L
B
VARIABLE 2
1
I
0
99999
L
C
VARIABLE 3
1
I
0
99999
L
Dep
VARIABLE 4
4
F
1
99999
L
Case 0
A
B
C
Dep
Case 1
1
1
1
1.00
Case 2
1
1
1
3.00
Case 3
1
1
1
4.00
Case 4
1
2
1
2.00
Case 5
1
2
1
3.00
Case 6
1
2
1
5.00
Case 7
1
3
1
3.00
Case 8
1
3
1
3.00
Case 9
1
3
1
6.00
Case 10
2
4
1
2.00
Case 11
2
4
1
4.00
Case 12
2
4
1
5.00
Case 13
2
5
1
3.00
Case 14
2
5
1
4.00
Case 15
2
5
1
5.00
Case 16
2
6
1
4.00
Case 17
2
6
1
5.00
Case 18
2
6
1
6.00
Case 19
3
7
1
3.00
Case 20
3
7
1
3.00
Case 21
3
7
1
5.00
Case 22
3
8
1
4.00
Case 23
3
8
1
5.00
Case 24
3
8
1
6.00
Case 25
3
9
1
6.00
Case 26
3
9
1
6.00
Case 27
3
9
1
8.00
Case 28
1
1
2
2.00
Case 29
1
1
2
4.00
Case 30
1
1
2
4.00
Case 31
1
2
2
2.00
Case 32
1
2
2
3.00
Case 33
1
2
2
6.00
Case 34
1
3
2
4.00
Case 35
1
3
2
4.00
Case 36
1
3
2
7.00
Case 37
2
4
2
3.00
Case 38
2
4
2
5.00
Case 39
2
4
2
6.00
Case 40
2
5
2
4.00
Case 41
2
5
2
5.00
Case 42
2
5
2
5.00
Case 43
2
6
2
2.00
Case 44
2
6
2
3.00
Case 45
2
6
2
4.00
Case 46
3
7
2
2.00
Case 47
3
7
2
2.00
Case 48
3
7
2
4.00
Case 49
3
8
2
5.00
Case 50
3
8
2
6.00
Case 51
3
8
2
7.00
Case 52
3
9
2
6.00
Case 53
3
9
2
6.00
Case 54
3
9
2
7.00

View File

@ -3,7 +3,7 @@ inherited ABCNestedForm: TABCNestedForm
Height = 481 Height = 481
Top = 191 Top = 191
Width = 843 Width = 843
Caption = 'ABCNestedForm' Caption = 'Three-Factor Nested ANOVA'
ClientHeight = 481 ClientHeight = 481
ClientWidth = 843 ClientWidth = 843
inherited ParamsPanel: TPanel inherited ParamsPanel: TPanel
@ -14,23 +14,23 @@ inherited ABCNestedForm: TABCNestedForm
inherited CloseBtn: TButton inherited CloseBtn: TButton
Left = 274 Left = 274
Top = 440 Top = 440
TabOrder = 17 TabOrder = 16
end end
inherited ComputeBtn: TButton inherited ComputeBtn: TButton
Left = 190 Left = 190
Top = 440 Top = 440
TabOrder = 16 TabOrder = 15
end end
inherited ResetBtn: TButton inherited ResetBtn: TButton
Left = 128 Left = 128
Top = 440 Top = 440
TabOrder = 15 TabOrder = 14
end end
inherited HelpBtn: TButton inherited HelpBtn: TButton
Tag = 170 Tag = 170
Left = 69 Left = 69
Top = 440 Top = 440
TabOrder = 14 TabOrder = 13
end end
inherited ButtonBevel: TBevel inherited ButtonBevel: TBevel
Top = 424 Top = 424
@ -40,9 +40,9 @@ inherited ABCNestedForm: TABCNestedForm
AnchorSideTop.Control = Label1 AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AInBtn AnchorSideRight.Control = AInBtn
AnchorSideBottom.Control = OptionsGroup AnchorSideBottom.Control = PlotOptionsGroup
Left = 0 Left = 0
Height = 285 Height = 327
Top = 17 Top = 17
Width = 144 Width = 144
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -209,12 +209,12 @@ inherited ABCNestedForm: TABCNestedForm
AnchorSideLeft.Control = AInBtn AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = FactorBEdit AnchorSideBottom.Control = FactorBEdit
Left = 186 Left = 184
Height = 15 Height = 15
Top = 177 Top = 177
Width = 115 Width = 115
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 6
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Caption = 'Factor B (Nested in A)' Caption = 'Factor B (Nested in A)'
ParentColor = False ParentColor = False
@ -223,12 +223,12 @@ inherited ABCNestedForm: TABCNestedForm
AnchorSideLeft.Control = AInBtn AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = DepEdit AnchorSideBottom.Control = DepEdit
Left = 186 Left = 184
Height = 15 Height = 15
Top = 25 Top = 25
Width = 102 Width = 102
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 6
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Caption = 'Dependent Variable' Caption = 'Dependent Variable'
ParentColor = False ParentColor = False
@ -240,12 +240,12 @@ inherited ABCNestedForm: TABCNestedForm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = AOutBtn AnchorSideBottom.Control = AOutBtn
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 186 Left = 184
Height = 23 Height = 23
Top = 118 Top = 118
Width = 143 Width = 145
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 6
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 6 TabOrder = 6
@ -258,12 +258,12 @@ inherited ABCNestedForm: TABCNestedForm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BOutBtn AnchorSideBottom.Control = BOutBtn
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 186 Left = 184
Height = 23 Height = 23
Top = 194 Top = 194
Width = 143 Width = 145
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 6
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 9 TabOrder = 9
@ -276,12 +276,12 @@ inherited ABCNestedForm: TABCNestedForm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DepOutBtn AnchorSideBottom.Control = DepOutBtn
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 186 Left = 184
Height = 23 Height = 23
Top = 42 Top = 42
Width = 143 Width = 145
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 6
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 3 TabOrder = 3
@ -294,12 +294,12 @@ inherited ABCNestedForm: TABCNestedForm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = COutBtn AnchorSideBottom.Control = COutBtn
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 186 Left = 184
Height = 23 Height = 23
Top = 270 Top = 270
Width = 143 Width = 145
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 6
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 12 TabOrder = 12
@ -309,49 +309,59 @@ inherited ABCNestedForm: TABCNestedForm
AnchorSideLeft.Control = AInBtn AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = FactorCEdit AnchorSideBottom.Control = FactorCEdit
Left = 186 Left = 184
Height = 15 Height = 15
Top = 253 Top = 253
Width = 88 Width = 88
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 6
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Caption = 'Factor C Variable' Caption = 'Factor C Variable'
ParentColor = False ParentColor = False
end end
object OptionsGroup: TRadioGroup[23] object PlotOptionsGroup: TGroupBox[23]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonBevel AnchorSideBottom.Control = ButtonBevel
Left = 8 Left = 0
Height = 114 Height = 72
Top = 310 Top = 352
Width = 239 Width = 106
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoFill = True
AutoSize = True AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Plot options' Caption = 'Plot options'
ChildSizing.LeftRightSpacing = 12 ClientHeight = 52
ChildSizing.TopBottomSpacing = 6 ClientWidth = 102
ChildSizing.HorizontalSpacing = 16 TabOrder = 17
ChildSizing.VerticalSpacing = 2 object ShowPlotsChk: TCheckBox
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize AnchorSideLeft.Control = PlotOptionsGroup
ChildSizing.EnlargeVertical = crsHomogenousChildResize AnchorSideTop.Control = PlotOptionsGroup
ChildSizing.ShrinkHorizontal = crsScaleChilds Left = 12
ChildSizing.ShrinkVertical = crsScaleChilds Height = 19
ChildSizing.Layout = cclLeftToRightThenTopToBottom Top = 6
ChildSizing.ControlsPerLine = 1 Width = 78
ClientHeight = 94 BorderSpacing.Left = 12
ClientWidth = 235 BorderSpacing.Top = 6
Items.Strings = ( BorderSpacing.Right = 12
'Plot means using 2D Horizontal Bars' Caption = 'Show plots'
'Plot means using 3D Horizontal Bars' Checked = True
'Plot means using 2D Vertical Bars' OnChange = ShowPlotsChkChange
'Plot means using 3D Vertical Bars' State = cbChecked
) TabOrder = 0
TabOrder = 13 end
object Plot3DChk: TCheckBox
AnchorSideLeft.Control = ShowPlotsChk
AnchorSideTop.Control = ShowPlotsChk
AnchorSideTop.Side = asrBottom
Left = 32
Height = 19
Top = 25
Width = 34
BorderSpacing.Left = 20
BorderSpacing.Bottom = 8
Caption = '3D'
OnChange = Plot3DChkChange
TabOrder = 1
end
end end
end end
inherited ParamsSplitter: TSplitter inherited ParamsSplitter: TSplitter
@ -364,5 +374,19 @@ inherited ABCNestedForm: TABCNestedForm
Width = 485 Width = 485
ActivePage = ReportPage ActivePage = ReportPage
TabIndex = 0 TabIndex = 0
inherited ReportPage: TTabSheet
Caption = 'ANOVA Results'
end
object MeansPage: TTabSheet[1]
Caption = 'Means'
end
inherited ChartPage: TTabSheet[2]
Caption = 'Plots'
end
end
object ChartStyles: TChartStyles[3]
Styles = <>
Left = 520
Top = 175
end end
end end

View File

@ -1,19 +1,36 @@
{ Test file: ABCNested.laz (imported from OpenStat sample data zip file)
Dependent: Dep
Factor A : A
Factor B : B
Factor C : C
}
unit ABCNestedUnit; unit ABCNestedUnit;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
{.$DEFINE SHOW_OLD_PLOTS}
interface interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, TAStyles, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls, StdCtrls, Buttons, ExtCtrls, ComCtrls, LCLVersion,
MainUnit, GraphLib, Globals, BasicStatsReportAndChartFormUnit; TACustomSeries,
{$IFDEF SHOW_OLD_PLOTS}
GraphLib,
{$ENDIF}
MainUnit, Globals, ReportFrameUnit, BasicStatsReportAndChartFormUnit;
type type
{ TABCNestedForm } { TABCNestedForm }
TABCNestedForm = class(TBasicStatsReportAndChartForm) TABCNestedForm = class(TBasicStatsReportAndChartForm)
ChartStyles: TChartStyles;
ShowPlotsChk: TCheckBox;
Plot3DChk: TCheckBox;
FactorCEdit: TEdit; FactorCEdit: TEdit;
FactorAEdit: TEdit; FactorAEdit: TEdit;
AInBtn: TBitBtn; AInBtn: TBitBtn;
@ -26,14 +43,15 @@ type
CInBtn: TBitBtn; CInBtn: TBitBtn;
DepOutBtn: TBitBtn; DepOutBtn: TBitBtn;
COutBtn: TBitBtn; COutBtn: TBitBtn;
PlotOptionsGroup: TGroupBox;
Label1: TLabel; Label1: TLabel;
Label2: TLabel; Label2: TLabel;
Label3: TLabel; Label3: TLabel;
Label4: TLabel; Label4: TLabel;
Label5: TLabel; Label5: TLabel;
Memo1: TLabel; Memo1: TLabel;
OptionsGroup: TRadioGroup;
Panel1: TPanel; Panel1: TPanel;
MeansPage: TTabSheet;
VarList: TListBox; VarList: TListBox;
procedure AInBtnClick(Sender: TObject); procedure AInBtnClick(Sender: TObject);
procedure AOutBtnClick(Sender: TObject); procedure AOutBtnClick(Sender: TObject);
@ -43,33 +61,46 @@ type
procedure COutBtnClick(Sender: TObject); procedure COutBtnClick(Sender: TObject);
procedure DepInBtnClick(Sender: TObject); procedure DepInBtnClick(Sender: TObject);
procedure DepOutBtnClick(Sender: TObject); procedure DepOutBtnClick(Sender: TObject);
procedure Plot3DChkChange(Sender: TObject);
procedure ShowPlotsChkChange(Sender: TObject);
procedure VarListDblClick(Sender: TObject); procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean); procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
private private
CellCount: IntDyneCube; CellCount: IntDyneCube;
ASS, BSS, CSS, ASumSqr, BSumSqr, CSumSqr, AMeans, BMeans, ASDs : DblDyneVec; ASS, BSS, CSS, ASumSqr, BSumSqr, CSumSqr, ASDs, BSDs, CSDs : DblDyneVec;
CMeans, BSDs, CSDs : DblDyneVec; ACSS,ACSumSqr, ACSDs, ABSS, ABSumSqr, ABSDs : DblDyneMat;
ACSS,ACSumSqr, ACMeans, ACSDs, ABSS, ABSumSqr, ABMeans, ABSDs : DblDyneMat;
ACount, BCount, CCount : IntDyneVec; ACount, BCount, CCount : IntDyneVec;
ACCount, ABCount : IntDyneMat; ACCount, ABCount : IntDyneMat;
CellSDs, SS, SumSqr, CellMeans : DblDyneCube; CellSDs, SS, SumSqr, CellMeans : DblDyneCube;
MinA, MinB, MaxA, MaxB, NoALevels, NoBLevels, ACol, BCol, YCol : integer; MinA, MinB, MaxA, MaxB, NoALevels, NoBLevels, ACol, BCol, YCol : integer;
CCol, MinC, MaxC, NoCLevels : integer; CCol, MinC, MaxC, NoCLevels : integer;
DepVar, FactorA, FactorB, FactorC : string;
SSTot, SumSqrTot, TotMean, MSTot, SSA, MSA, SSB, MSB, SSW, MSW : double; SSTot, SumSqrTot, TotMean, MSTot, SSA, MSA, SSB, MSB, SSW, MSW : double;
SSC, MSC, SSAC, MSAC, SSBwAC, SSAB, MSBwAC : double; SSC, MSC, SSAC, MSAC, SSBwAC, SSAB, MSBwAC : double;
TotN, dfA, dfBwA, dfwcell, dftotal, dfC, dfAC, dfBwAC : integer; TotN, dfA, dfBwA, dfwcell, dftotal, dfC, dfAC, dfBwAC : integer;
ColNoSelected: IntDyneVec; ColNoSelected: IntDyneVec;
function GetVars: Boolean; AMeans, BMeans, CMeans: DblDyneVec;
ABMeans, ACMeans: DblDyneMat;
function GetVariables: Boolean;
procedure GetMemory; procedure GetMemory;
procedure GetSums; procedure GetSums;
procedure ShowMeans(AReport: TStrings); procedure ShowMeans;
procedure GetResults; procedure GetResults;
procedure ShowResults(AReport: TStrings); procedure ShowResults;
procedure ReleaseMemory; procedure ReleaseMemory;
procedure TwoWayPlot; procedure TwoWayPlot;
{$IFDEF SHOW_OLD_PLOTS}
procedure OldTwoWayPlot;
{$ENDIF}
private
FMeansReportFrame: TReportFrame;
FChartCombobox: TCombobox;
FSeries: TChartSeries;
procedure PopulateChartCombobox;
procedure SelectPlot(Sender: TObject);
protected protected
procedure AdjustConstraints; override; procedure AdjustConstraints; override;
@ -90,7 +121,8 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
Math, MathUnit; TAChartUtils, TACustomSource, TALegend, TASeries,
Utils, Math, MathUnit, ChartFrameUnit;
{ TABCNestedForm } { TABCNestedForm }
@ -98,8 +130,23 @@ uses
constructor TABCNestedForm.Create(AOwner: TComponent); constructor TABCNestedForm.Create(AOwner: TComponent);
begin begin
inherited; inherited;
FMeansReportFrame := TReportFrame.Create(MeansPage);
FMeansReportFrame.Parent := MeansPage;
FMeansReportFrame.Align := alClient;
InitToolbar(FMeansReportFrame.ReportToolbar, tpTop);
MeansPage.PageIndex := 1;
FChartFrame.Chart.Margins.Bottom := 0;
AddComboboxToToolbar(FChartFrame.ChartToolbar, 'Plots:', FChartCombobox);
FChartCombobox.OnSelect := @SelectPlot;
{$IFDEF SHOW_OLD_PLOTS}
if GraphFrm = nil then if GraphFrm = nil then
Application.CreateForm(TGraphFrm, GraphFrm); Application.CreateForm(TGraphFrm, GraphFrm);
{$ENDIF}
PageControl.ActivePageIndex := 0;
end; end;
@ -112,7 +159,6 @@ begin
MaxValue([Label2.Width, Label3.Width, Label4.Width, Label5.Width])*2 + AInBtn.Width + VarList.BorderSpacing.Right*2 MaxValue([Label2.Width, Label3.Width, Label4.Width, Label5.Width])*2 + AInBtn.Width + VarList.BorderSpacing.Right*2
); );
ParamsPanel.Constraints.MinHeight := COutBtn.Top + COutBtn.Height + ParamsPanel.Constraints.MinHeight := COutBtn.Top + COutBtn.Height +
VarList.BorderSpacing.Bottom + OptionsGroup.Height +
ButtonBevel.Height + CloseBtn.Height + CloseBtn.BorderSpacing.Top; ButtonBevel.Height + CloseBtn.Height + CloseBtn.BorderSpacing.Top;
end; end;
@ -190,23 +236,19 @@ end;
procedure TABCNestedForm.Compute; procedure TABCNestedForm.Compute;
var
lReport: TStrings;
begin begin
lReport := TStringList.Create; if GetVariables then
try begin
if GetVars then GetMemory;
begin GetSums;
GetMemory; ShowMeans;
GetSums; GetResults;
ShowMeans(lReport); ShowResults;
GetResults; TwoWayPlot;
ShowResults(lReport); {$IFDEF SHOW_OLD_PLOTS}
TwoWayPlot; OldTwoWayPlot;
ReleaseMemory; {$ENDIF}
end; ReleaseMemory;
finally
lReport.Free;
end; end;
end; end;
@ -236,22 +278,59 @@ begin
end; end;
function TABCNestedForm.GetVars: Boolean; procedure TABCNestedForm.Plot3DChkChange(Sender: TObject);
begin
if FSeries is TBarSeries then
begin
if Plot3dChk.Checked then
TBarSeries(FSeries).Depth := 20
else
TBarSeries(FSeries).Depth := 0;
end;
end;
procedure TABCNestedForm.ShowPlotsChkChange(Sender: TObject);
begin
ChartPage.TabVisible := ShowPlotsChk.Checked;
Plot3DChk.Enabled := ShowPlotsChk.Checked;
end;
procedure TABCNestedForm.PopulateChartCombobox;
var
a, b, c: String;
idx: Integer;
begin
idx := FChartCombobox.ItemIndex;
a := FactorAEdit.Text;
b := FactorBEdit.Text;
c := FactorCEdit.Text;
FChartCombobox.Items.Clear;
FChartCombobox.Items.Add(a);
FChartCombobox.Items.Add(b);
FChartCombobox.Items.Add(c);
FChartCombobox.Items.Add(Format('%s x %s', [a, b]));
FChartCombobox.Items.Add(Format('%s x %s', [a, c]));
FChartCombobox.ItemIndex := EnsureRange(idx, 0, FChartCombobox.Items.Count-1);
end;
function TABCNestedForm.GetVariables: Boolean;
var var
i, group: integer; i, group: integer;
strvalue, cellstring: string; strvalue, cellstring: string;
begin begin
Result := false; Result := false;
SetLength(ColNoSelected,4); SetLength(ColNoSelected, 4);
DepVar := DepEdit.Text; ACol := -1;
FactorA := FactorAEdit.Text; BCol := -1;
FactorB := FactorBEdit.Text; CCol := -1;
FactorC := FactorCEdit.Text; YCol := -1;
ACol := 0;
BCol := 0;
CCol := 0;
YCol := 0;
MinA := MaxInt; MinA := MaxInt;
MaxA := -MaxInt; MaxA := -MaxInt;
MinB := MaxInt; MinB := MaxInt;
@ -261,28 +340,28 @@ begin
for i := 1 to NoVariables do for i := 1 to NoVariables do
begin begin
strvalue := Trim(OS3MainFrm.DataGrid.Cells[i,0]); strvalue := Trim(OS3MainFrm.DataGrid.Cells[i,0]);
if FactorA = strvalue then if FactorAEdit.Text = strvalue then
begin begin
ACol := i; ACol := i;
ColNoSelected[0] := i; ColNoSelected[0] := i;
end; end;
if FactorB = strvalue then if FactorBEdit.Text = strvalue then
begin begin
BCol := i; BCol := i;
ColNoSelected[1] := i; ColNoSelected[1] := i;
end; end;
if FactorC = strvalue then if FactorCEdit.Text = strvalue then
begin begin
CCol := i; CCol := i;
ColNoSelected[2] := i; ColNoSelected[2] := i;
end; end;
if DepVar = strvalue then if DepEdit.Text = strvalue then
begin begin
YCol := i; YCol := i;
ColNoSelected[3] := i; ColNoSelected[3] := i;
end; end;
end; end;
if (ACol = 0) or (BCol = 0) or (CCol = 0) or (YCol = 0) then if (ACol = -1) or (BCol = -1) or (CCol = -1) or (YCol = -1) then
begin begin
MessageDlg('Select a variable for each entry box.', mtError, [mbOK], 0); MessageDlg('Select a variable for each entry box.', mtError, [mbOK], 0);
exit; exit;
@ -528,62 +607,74 @@ begin
end; end;
procedure TABCNestedForm.ShowMeans(AReport: TStrings); procedure TABCNestedForm.ShowMeans;
var var
lReport: TStrings;
i, j, k : integer; i, j, k : integer;
begin begin
AReport.Add('Nested ANOVA by Bill Miller'); lReport := TStringList.Create;
AReport.Add('File Analyzed: %s', [OS3MainFrm.FileNameEdit.Text]); try
AReport.Add(''); lReport.Add('Nested ANOVA by Bill Miller');
lReport.Add('');
lReport.Add('File analyzed: %s', [OS3MainFrm.FileNameEdit.Text]);
lReport.Add('Factor A: %s', [FactorAEdit.Text]);
lReport.Add('Factor B: %s', [FactorBEdit.Text]);
lReport.Add('Factor C: %s', [FactorCEdit.Text]);
lReport.Add('');
AReport.Add('CELL MEANS'); lReport.Add('CELL MEANS');
AReport.Add('A LEVEL BLEVEL CLEVEL MEAN STD.DEV.'); lReport.Add('A LEVEL BLEVEL CLEVEL MEAN STD.DEV.');
for i := 0 to NoALevels-1 do for i := 0 to NoALevels-1 do
for j := 0 to NoBLevels-1 do for j := 0 to NoBLevels-1 do
for k := 0 to NoCLevels-1 do for k := 0 to NoCLevels-1 do
if CellCount[j,i,k] > 0 then if CellCount[j,i,k] > 0 then
AReport.Add('%5d %5d %5d %10.4f %10.4f', [i+MinA, j+MinB, k+MinC, CellMeans[j,i,k], CellSDs[j,i,k]]); lReport.Add('%5d %5d %5d %10.4f %10.4f', [i+MinA, j+MinB, k+MinC, CellMeans[j,i,k], CellSDs[j,i,k]]);
AReport.Add(''); lReport.Add('');
AReport.Add('A MARGIN MEANS'); lReport.Add('A MARGIN MEANS');
AReport.Add('A LEVEL MEAN STD.DEV.'); lReport.Add('A LEVEL MEAN STD.DEV.');
for i := 0 to NoALevels-1 do for i := 0 to NoALevels-1 do
AReport.Add('%5d %10.3f %10.3f', [i+MinA, AMeans[i], ASDs[i]]); lReport.Add('%5d %10.3f %10.3f', [i+MinA, AMeans[i], ASDs[i]]);
AReport.Add(''); lReport.Add('');
AReport.Add('B MARGIN MEANS'); lReport.Add('B MARGIN MEANS');
AReport.Add('B LEVEL MEAN STD.DEV.'); lReport.Add('B LEVEL MEAN STD.DEV.');
for i := 0 to NoBLevels-1 do for i := 0 to NoBLevels-1 do
if BCount[i] > 0 then if BCount[i] > 0 then
AReport.Add('%5d %10.3f %10.3f', [i+MinB, BMeans[i], BSDs[i]]); lReport.Add('%5d %10.3f %10.3f', [i+MinB, BMeans[i], BSDs[i]]);
AReport.Add(''); lReport.Add('');
AReport.Add('C MARGIN MEANS'); lReport.Add('C MARGIN MEANS');
AReport.Add('C LEVEL MEAN STD.DEV.'); lReport.Add('C LEVEL MEAN STD.DEV.');
for i := 0 to NoCLevels-1 do for i := 0 to NoCLevels-1 do
if CCount[i] > 0 then if CCount[i] > 0 then
AReport.Add('%5d %10.3f %10.3f', [i+MinC, CMeans[i], CSDs[i]]); lReport.Add('%5d %10.3f %10.3f', [i+MinC, CMeans[i], CSDs[i]]);
AReport.Add(''); lReport.Add('');
AReport.Add('AB MARGIN MEANS'); lReport.Add('AB MARGIN MEANS');
AReport.Add('A LEVEL B LEVEL MEAN STD.DEV.'); lReport.Add('A LEVEL B LEVEL MEAN STD.DEV.');
for i := 0 to NoALevels-1 do for i := 0 to NoALevels-1 do
for j := 0 to NoBLevels-1 do for j := 0 to NoBLevels-1 do
if ABCount[i,j] > 0 then if ABCount[i,j] > 0 then
AReport.Add('%5d %5D %10.3f %10.3f', [i+MinA, j+MinB, ABMeans[i,j], ABSDs[i,j]]); lReport.Add('%5d %5D %10.3f %10.3f', [i+MinA, j+MinB, ABMeans[i,j], ABSDs[i,j]]);
AReport.Add(''); lReport.Add('');
AReport.Add('AC MARGIN MEANS'); lReport.Add('AC MARGIN MEANS');
AReport.Add('A LEVEL C LEVEL MEAN STD.DEV.'); lReport.Add('A LEVEL C LEVEL MEAN STD.DEV.');
for i := 0 to NoALevels-1 do for i := 0 to NoALevels-1 do
for j := 0 to NoCLevels-1 do for j := 0 to NoCLevels-1 do
if ACCount[i,j] > 0 then if ACCount[i,j] > 0 then
AReport.Add('%5d %5D %10.3f %10.3f',[i+MinA, j+MinC, ACMeans[i,j], ACSDs[i,j]]); lReport.Add('%5d %5D %10.3f %10.3f',[i+MinA, j+MinC, ACMeans[i,j], ACSDs[i,j]]);
AReport.Add(''); lReport.Add('');
AReport.Add('GRAND MEAN = %10.3f', [TotMean]); lReport.Add('GRAND MEAN = %10.3f', [TotMean]);
AReport.Add(''); lReport.Add('');
// OutputFrm.ShowModal;
FMeansReportFrame.DisplayReport(lReport);
finally
lReport.Free;
end;
end; end;
@ -685,38 +776,54 @@ begin
end; end;
procedure TABCNestedForm.ShowResults(AReport: TStrings); procedure TABCNestedForm.ShowResults;
VAR var
lReport: TStrings;
F, PF : double; F, PF : double;
begin begin
AReport.Add(''); lReport := TStringList.Create;
AReport.Add('ANOVA TABLE'); try
AReport.Add('SOURCE D.F. SS MS F PROB.'); lReport.Add('Nested ANOVA by Bill Miller');
lReport.Add('');
lReport.Add('File analyzed: %s', [OS3MainFrm.FileNameEdit.Text]);
lReport.Add('Factor A: %s', [FactorAEdit.Text]);
lReport.Add('Factor B: %s', [FactorBEdit.Text]);
lReport.Add('Factor C: %s', [FactorCEdit.Text]);
lReport.Add('');
lReport.Add('ANOVA TABLE');
lReport.Add('------------------------------------------------------------');
lReport.Add('SOURCE D.F. SS MS F PROB. ');
lReport.Add('--------- ---- ---------- ---------- --------- ---------');
F := MSA / MSW; F := MSA / MSW;
PF := ProbF(F,dfA,dfwcell); PF := ProbF(F,dfA,dfwcell);
AReport.Add('A %4D %10.3f%10.3f%10.3f%10.3f', [dfA, SSA, MSA, F, PF]); lReport.Add('A %4d %10.3f %10.3f %9.3f %9.3f', [dfA, SSA, MSA, F, PF]);
F := MSB / MSW; F := MSB / MSW;
PF := ProbF(F,dfBwA,dfwcell); PF := ProbF(F,dfBwA,dfwcell);
AReport.Add('B(A) %4D %10.3f%10.3f%10.3f%10.3f', [dfBwA, SSB, MSB, F, PF]); lReport.Add('B(A) %4d %10.3f %10.3f %9.3f %9.3f', [dfBwA, SSB, MSB, F, PF]);
F := MSC / MSW; F := MSC / MSW;
PF := ProbF(F,dfC,dfwcell); PF := ProbF(F,dfC,dfwcell);
AReport.Add('C %4D %10.3f%10.3f%10.3f%10.3f', [dfC, SSC, MSC, F, PF]); lReport.Add('C %4d %10.3f %10.3f %9.3f %9.3f', [dfC, SSC, MSC, F, PF]);
F := MSAC / MSW; F := MSAC / MSW;
PF := ProbF(F,dfAC,dfwcell); PF := ProbF(F,dfAC,dfwcell);
AReport.Add('AxC %4D %10.3f%10.3f%10.3f%10.3f', [dfAC, SSAC, MSAC, F, PF]); lReport.Add('AxC %4d %10.3f %10.3f %9.3f %9.3f', [dfAC, SSAC, MSAC, F, PF]);
F := MSBwAC / MSW; F := MSBwAC / MSW;
PF := ProbF(F,dfBwAC,dfwcell); PF := ProbF(F,dfBwAC,dfwcell);
AReport.Add('B(A)xC %4D %10.3f%10.3f%10.3f%10.3f', [dfBwAC, SSBwAC, MSBwAC, F, PF]); lReport.Add('B(A)xC %4d %10.3f %10.3f %9.3f %9.3f', [dfBwAC, SSBwAC, MSBwAC, F, PF]);
AReport.Add('w.cells %4D %10.3f%10.3f', [dfwcell, SSW, MSW]); lReport.Add('w.cells %4d %10.3f %10.3f', [dfwcell, SSW, MSW]);
AReport.Add('Total %4D %10.3f', [dftotal, SSTot]); lReport.Add('Total %4d %10.3f', [dftotal, SSTot]);
lReport.Add('------------------------------------------------------------');
FReportFrame.DisplayReport(AReport); FReportFrame.DisplayReport(lReport);
finally
lReport.Free;
end;
end; end;
@ -725,11 +832,11 @@ begin
ColNoSelected := nil; ColNoSelected := nil;
ABSDs := nil; ABSDs := nil;
ABCount := nil; ABCount := nil;
ABMeans := nil; // ABMeans := nil;
ABSumSqr := nil; ABSumSqr := nil;
ABSS := nil; ABSS := nil;
ACSDs := nil; ACSDs := nil;
ACMeans := nil; // ACMeans := nil;
ACCount := nil; ACCount := nil;
ACSumSqr := nil; ACSumSqr := nil;
ACSS := nil; ACSS := nil;
@ -739,9 +846,9 @@ begin
CCount := nil; CCount := nil;
BCount := nil; BCount := nil;
ACount := nil; ACount := nil;
CMeans := nil; // CMeans := nil;
BMeans := nil; // BMeans := nil;
AMeans := nil; // AMeans := nil;
CSumSqr := nil; CSumSqr := nil;
BSumSqr := nil; BSumSqr := nil;
ASumSqr := nil; ASumSqr := nil;
@ -762,6 +869,11 @@ var
begin begin
inherited; inherited;
if FMeansReportFrame <> nil then
FMeansReportFrame.Clear;
if FChartCombobox <> nil then
FChartCombobox.Items.Clear;
VarList.Items.Clear; VarList.Items.Clear;
for i := 1 to NoVariables do for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
@ -771,14 +883,156 @@ begin
FactorCEdit.Clear; FactorCEdit.Clear;
DepEdit.Clear; DepEdit.Clear;
OptionsGroup.ItemIndex := 3;
OptionsGroup.ItemIndex := 3;
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TABCNestedForm.SelectPlot(Sender: TObject);
var
i, j, k, idx: Integer;
item: PChartDataItem;
begin
ChartStyles.Styles.Clear;
FSeries.Clear;
case FChartComboBox.ItemIndex of
0: begin // Plot means vs factor A
FSeries.ListSource.YCount := 1;
for i := 0 to NoALevels-1 do
FSeries.AddXY(MinA + i, AMeans[i], IntToStr(MinA + i));
FChartFrame.SetXTitle(FactorAEdit.Text + ' codes');
FChartFrame.SetTitle('Factor ' + FactorAEdit.Text);
end;
1: begin // Plot means vs factor B
FSeries.ListSource.YCount := 1;
for i := 0 to NoBLevels-1 do
FSeries.AddXY(MinB + i, BMeans[i], IntToStr(MinB + i));
FChartFrame.SetXTitle(FactorBEdit.Text + ' codes');
FChartFrame.SetTitle('Factor ' + FactorBEdit.Text);
end;
2: begin // Plot means vs factor C
FSeries.ListSource.YCount := 1;
for i := 0 to NoCLevels-1 do
FSeries.AddXY(MinC + i, CMeans[i], IntToStr(MinC + i));
FChartFrame.SetXTitle(FactorCEdit.Text + ' codes');
FChartFrame.SetTitle('Factor ' + FactorCEdit.Text);
end;
3: begin // Plot interaction AxB
FSeries.ListSource.YCount := NoALevels;
for j := 0 to NoBLevels-1 do
begin
idx := FSeries.AddXY(MinB + j, NaN, IntToStr(MinB + j));
item := FSeries.Source.Item[idx];
for i := 0 to NoALevels-1 do
item^.SetY(i, ABMeans[i, j]);
end;
FChartFrame.SetTitle(Format('Factor "%s" x Factor "%s"', [
FactorAEdit.Text, FactorBEdit.Text]));
FChartFrame.SetXTitle(FactorBEdit.Text + ' codes');
for i := 0 to NoALevels-1 do
with TChartStyle(ChartStyles.Styles.Add) do
begin
Brush.Color := DATA_COLORS[i mod Length(DATA_COLORS)];
UseBrush := true;
Text := Format('%s = %s', [FactorAEdit.Text, IntToStr(MinA+i)]);
end;
end;
4: begin // Plot interaction AxC
FSeries.ListSource.YCount := NoALevels;
for k := 0 to NoCLevels-1 do
begin
idx := FSeries.AddXY(MinC + k, NaN, IntToStr(MinC + k));
item := FSeries.Source.Item[idx];
for i := 0 to NoALevels-1 do
item^.SetY(i, ACMeans[i, k]);
end;
FChartFrame.SetTitle(Format('Factor "%s" x Factor "%s"', [
FactorAEdit.Text, FactorCEdit.Text]));
FChartFrame.SetXTitle(FactorCEdit.Text + ' codes');
for i := 0 to NoALevels-1 do
with TChartStyle(ChartStyles.Styles.Add) do
begin
Brush.Color := DATA_COLORS[i mod Length(DATA_COLORS)];
UseBrush := true;
Text := Format('%s = %s', [FactorAEdit.Text, IntToStr(MinA+i)]);
end;
end;
end;
(*
GetDataIndices(ix, iy,iz);
if (ix = 1) and (iy = 2) then
begin
FSeries.ListSource.YCount := NF2Cells;
for i := 0 to NF1Cells-1 do
begin
idx := FSeries.AddXY(minF1 + i, NaN, IntToStr(minF1 + i));
item := FSeries.Source.Item[idx];
for j := 0 to NF2Cells-1 do
item^.SetY(j, wsum[i,j,iz] / ncnt[i,j,iz]);
end;
FChartFrame.SetTitle(Format('Factor "%s" x Factor "%s"' + LineEnding + '"%s" = %d', [
Factor1Edit.Text, Factor2Edit.Text, Factor3Edit.Text, MinF3 + iz]));
FChartFrame.SetXTitle(Factor1Edit.Text + ' codes');
for j := 0 to NF2Cells-1 do
with TChartStyle(FStyles.styles.Add) do
begin
Brush.Color := DATA_COLORS[j mod Length(DATA_COLORS)];
UseBrush := True;
Text := Format('%s = %s', [Factor2Edit.Text, IntToStr(MinF2 + j)]);
end;
end
else *)
if (FSeries is TBarSeries) then
begin
if ChartStyles.Styles.Count > 0 then
begin
TBarSeries(FSeries).Styles := ChartStyles;
FSeries.Legend.Multiplicity := lmStyle;
end else
FSeries.Legend.Multiplicity := lmSingle;
end;
FChartFrame.Chart.BottomAxis.Marks.Source := FSeries.Source;
FChartFrame.Chart.BottomAxis.Marks.Style := smsLabel;
FChartFrame.Chart.Legend.Visible := FSeries.Source.YCount > 1;
FChartFrame.UpdateBtnStates;
end;
procedure TABCNestedForm.TwoWayPlot; procedure TABCNestedForm.TwoWayPlot;
begin
if not ShowPlotsChk.Checked then
begin
ChartPage.TabVisible := false;
exit;
end;
FChartFrame.Clear; // this destroys the series
FChartFrame.SetYTitle('Mean');
FSeries := FChartFrame.PlotXY(ptBars, nil, nil, nil, nil, '', DATA_Colors[0]);
with TBarSeries(FSeries) do
begin
Stacked := false;
{$IF LCL_FullVersion >= 2010000}
DepthBrightnessDelta := -30;
{$IFEND}
end;
if Plot3DChk.Checked then
FSeries.Depth := 20;
FChartCombobox.Parent.Left := 0;
PopulateChartCombobox;
SelectPlot(nil);
ChartPage.TabVisible := true;
end;
{$IFDEF SHOW_OLD_PLOTS}
procedure TABCNestedForm.OldTwoWayPlot;
var var
plottype, i, j, k : integer; plottype, i, j, k : integer;
maxmean, XBar : double; maxmean, XBar : double;
@ -808,8 +1062,8 @@ begin
end; end;
GraphFrm.nosets := 1; GraphFrm.nosets := 1;
GraphFrm.nbars := NoALevels; GraphFrm.nbars := NoALevels;
GraphFrm.Heading := FactorA; GraphFrm.Heading := FactorAEdit.Text;
title := FactorA + ' Group Codes'; title := FactorAEdit.Text + ' Group Codes';
GraphFrm.XTitle := title; GraphFrm.XTitle := title;
GraphFrm.YTitle := 'Mean'; GraphFrm.YTitle := 'Mean';
GraphFrm.barwideprop := 0.5; GraphFrm.barwideprop := 0.5;
@ -843,7 +1097,7 @@ begin
GraphFrm.nosets := 1; GraphFrm.nosets := 1;
GraphFrm.nbars := NoBLevels; GraphFrm.nbars := NoBLevels;
GraphFrm.Heading := 'FACTOR B'; GraphFrm.Heading := 'FACTOR B';
title := FactorB + ' Group Codes'; title := FactorBEdit.Text + ' Group Codes';
GraphFrm.XTitle := title; GraphFrm.XTitle := title;
GraphFrm.YTitle := 'Mean'; GraphFrm.YTitle := 'Mean';
GraphFrm.barwideprop := 0.5; GraphFrm.barwideprop := 0.5;
@ -877,7 +1131,7 @@ begin
GraphFrm.nosets := 1; GraphFrm.nosets := 1;
GraphFrm.nbars := NoCLevels; GraphFrm.nbars := NoCLevels;
GraphFrm.Heading := 'FACTOR C'; GraphFrm.Heading := 'FACTOR C';
title := FactorB + ' Group Codes'; title := FactorBEdit.Text + ' Group Codes';
GraphFrm.XTitle := title; GraphFrm.XTitle := title;
GraphFrm.YTitle := 'Mean'; GraphFrm.YTitle := 'Mean';
GraphFrm.barwideprop := 0.5; GraphFrm.barwideprop := 0.5;
@ -922,7 +1176,7 @@ begin
GraphFrm.nosets := NoALevels; GraphFrm.nosets := NoALevels;
GraphFrm.nbars := NoBLevels; GraphFrm.nbars := NoBLevels;
GraphFrm.Heading := 'FACTOR A x Factor B within C' + IntToStr(k+1); GraphFrm.Heading := 'FACTOR A x Factor B within C' + IntToStr(k+1);
title := FactorB + ' Group Codes'; title := FactorBEdit.Text + ' Group Codes';
GraphFrm.XTitle := title; GraphFrm.XTitle := title;
GraphFrm.YTitle := 'Mean'; GraphFrm.YTitle := 'Mean';
GraphFrm.barwideprop := 0.5; GraphFrm.barwideprop := 0.5;
@ -966,7 +1220,7 @@ begin
GraphFrm.nosets := NoALevels; GraphFrm.nosets := NoALevels;
GraphFrm.nbars := NoCLevels; GraphFrm.nbars := NoCLevels;
GraphFrm.Heading := 'FACTOR A x Factor C within B ' + IntToStr(j+1); GraphFrm.Heading := 'FACTOR A x Factor C within B ' + IntToStr(j+1);
title := FactorC + ' Group Codes'; title := FactorCEdit.Text + ' Group Codes';
GraphFrm.XTitle := title; GraphFrm.XTitle := title;
GraphFrm.YTitle := 'Mean'; GraphFrm.YTitle := 'Mean';
GraphFrm.barwideprop := 0.5; GraphFrm.barwideprop := 0.5;
@ -978,18 +1232,22 @@ begin
GraphFrm.WallColor := clDkGray; GraphFrm.WallColor := clDkGray;
GraphFrm.FloorColor := clLtGray; GraphFrm.FloorColor := clLtGray;
GraphFrm.ShowBackWall := true; GraphFrm.ShowBackWall := true;
// GraphFrm.ShowModal; GraphFrm.ShowModal;
end; end;
GraphFrm.Xpoints := nil; GraphFrm.Xpoints := nil;
GraphFrm.Ypoints := nil; GraphFrm.Ypoints := nil;
XValue := nil; XValue := nil;
end; end;
{$ENDIF}
procedure TABCNestedForm.UpdateBtnStates; procedure TABCNestedForm.UpdateBtnStates;
begin begin
inherited; inherited;
if FMeansReportFrame <> nil then
FMeansReportFrame.UpdateBtnStates;
AInBtn.Enabled := (VarList.ItemIndex > -1) and (FactorAEdit.Text = ''); AInBtn.Enabled := (VarList.ItemIndex > -1) and (FactorAEdit.Text = '');
BInBtn.Enabled := (VarList.ItemIndex > -1) and (FactorBEdit.Text = ''); BInBtn.Enabled := (VarList.ItemIndex > -1) and (FactorBEdit.Text = '');
CInBtn.Enabled := (VarList.ItemIndex > -1) and (FactorCEdit.Text = ''); CInBtn.Enabled := (VarList.ItemIndex > -1) and (FactorCEdit.Text = '');
@ -1009,14 +1267,15 @@ begin
index := VarList.ItemIndex; index := VarList.ItemIndex;
if index > -1 then begin if index > -1 then begin
s := VarList.Items[index]; s := VarList.Items[index];
if FactorAEdit.Text = '' then if DepEdit.Text = '' then
DepEdit.Text := s
else if FactorAEdit.Text = '' then
FactorAEdit.Text := s FactorAEdit.Text := s
else if FactorBEdit.Text = '' then else if FactorBEdit.Text = '' then
FactorBEdit.Text := s FactorBEdit.Text := s
else if FactorCEdit.Text = '' then else if FactorCEdit.Text = '' then
FactorCEdit.Text := s FactorCEdit.Text := s;
else if DepEdit.Text = '' then VarList.Items.Delete(index);
DepEdit.Text := s;
UpdateBtnStates; UpdateBtnStates;
end; end;
end; end;

View File

@ -226,8 +226,7 @@ inherited AxSAnovaForm: TAxSAnovaForm
inherited PageControl: TPageControl inherited PageControl: TPageControl
Height = 397 Height = 397
Width = 457 Width = 457
ActivePage = ReportPage TabIndex = 2
TabIndex = 0
inherited ReportPage: TTabSheet inherited ReportPage: TTabSheet
Caption = 'ANOVA Results' Caption = 'ANOVA Results'
end end

View File

@ -677,15 +677,16 @@ inherited BlksAnovaForm: TBlksAnovaForm
Height = 561 Height = 561
Width = 485 Width = 485
ActivePage = PosthocPage ActivePage = PosthocPage
TabIndex = 2
inherited ReportPage: TTabSheet inherited ReportPage: TTabSheet
Caption = 'ANOVA Results' Caption = 'ANOVA Results'
end end
object PosthocPage: TTabSheet[1] inherited ChartPage: TTabSheet
Caption = 'Plots'
end
object PosthocPage: TTabSheet[2]
Caption = 'Post-Hoc' Caption = 'Post-Hoc'
TabVisible = False TabVisible = False
end end
inherited ChartPage: TTabSheet[2]
Caption = 'Plots'
end
end end
end end

View File

@ -195,6 +195,8 @@ begin
FStyles := TChartStyles.Create(FChartFrame); FStyles := TChartStyles.Create(FChartFrame);
AddComboboxToToolbar(FChartFrame.ChartToolbar, 'Plots:', FChartCombobox);
{
panel := TPanel.Create(FChartFrame.ChartToolbar); panel := TPanel.Create(FChartFrame.ChartToolbar);
lbl := TLabel.Create(panel); lbl := TLabel.Create(panel);
lbl.Parent := panel; lbl.Parent := panel;
@ -217,7 +219,7 @@ begin
panel.AutoSize := true; panel.AutoSize := true;
panel.BevelInner := bvNone; panel.BevelInner := bvNone;
panel.BevelOuter := bvNone; panel.BevelOuter := bvNone;
}
FChartFrame.Chart.Margins.Bottom := 0; FChartFrame.Chart.Margins.Bottom := 0;
PageControl.ActivePageIndex := 0; PageControl.ActivePageIndex := 0;
@ -1538,6 +1540,11 @@ var
begin begin
inherited; inherited;
if FPostHocReportFrame <> nil then
FPostHocReportFrame.Clear;
if FChartCombobox <> nil then
FChartCombobox.Items.Clear;
VarList.Clear; VarList.Clear;
for i := 1 to NoVariables do for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);

View File

@ -5,7 +5,7 @@ unit Utils;
interface interface
uses uses
Classes, SysUtils, Graphics, Controls, StdCtrls, ComCtrls, Dialogs, Forms, Classes, SysUtils, Graphics, Controls, StdCtrls, ExtCtrls, ComCtrls, Dialogs, Forms,
Globals; Globals;
type type
@ -14,6 +14,8 @@ type
procedure InitForm(AForm: TForm); procedure InitForm(AForm: TForm);
procedure AddButtonToToolbar(AToolButton: TToolButton; AToolBar: TToolBar); procedure AddButtonToToolbar(AToolButton: TToolButton; AToolBar: TToolBar);
procedure AddComboboxToToolbar(AToolBar: TToolbar; ACaption: String;
out ACombobox: TCombobox);
procedure InitToolbar(AToolbar: TToolbar; APosition: TToolbarPosition); procedure InitToolbar(AToolbar: TToolbar; APosition: TToolbarPosition);
function AnySelected(AListbox: TListBox): Boolean; function AnySelected(AListbox: TListBox): Boolean;
@ -44,6 +46,48 @@ begin
end; end;
procedure AddComboboxToToolbar(AToolbar: TToolbar; ACaption: String;
out AComboBox: TComboBox);
var
panel: TPanel;
lbl: TLabel = nil;
begin
panel := TPanel.Create(AToolbar);
if ACaption <> '' then
begin
lbl := TLabel.Create(panel);
lbl.Parent := panel;
lbl.Caption := ACaption;
end;
ACombobox := TCombobox.Create(panel);
ACombobox.Parent := panel;
ACombobox.Style := csDropdownList;
ACombobox.DropdownCount := 24;
ACombobox.Items.Clear;
ACombobox.Constraints.MinWidth := 300;
if lbl <> nil then
begin
lbl.AnchorSideLeft.Side := asrTop;
lbl.AnchorSideLeft.Control := panel;
lbl.AnchorSideTop.Side := asrCenter;
lbl.AnchorSideTop.Control := ACombobox;
end;
ACombobox.AnchorSideLeft.Control := lbl;
ACombobox.AnchorSideLeft.Side := asrBottom;
ACombobox.BorderSpacing.Left := 6;
ACombobox.BorderSpacing.Around := 2;
panel.Parent := AToolbar;
panel.AutoSize := true;
panel.BevelInner := bvNone;
panel.BevelOuter := bvNone;
panel.Left := 0;
end;
procedure InitForm(AForm: TForm); procedure InitForm(AForm: TForm);
begin begin
AForm.Width := AForm.Scale96ToFont(DEFAULT_WIDTH); AForm.Width := AForm.Scale96ToFont(DEFAULT_WIDTH);