diff --git a/applications/lazstats/source/LazStats.lpi b/applications/lazstats/source/LazStats.lpi
index 8ae5d8b4c..17e000a56 100644
--- a/applications/lazstats/source/LazStats.lpi
+++ b/applications/lazstats/source/LazStats.lpi
@@ -752,674 +752,674 @@
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/applications/lazstats/source/LazStats.lpr b/applications/lazstats/source/LazStats.lpr
index d51497e13..43edd4608 100644
--- a/applications/lazstats/source/LazStats.lpr
+++ b/applications/lazstats/source/LazStats.lpr
@@ -9,7 +9,7 @@ uses
Interfaces, // this includes the LCL widgetset
Forms, tachartlazaruspkg, tachartprint, lhelpcontrolpkg, Globals, LicenseUnit,
OptionsUnit, MainDM, MainUnit, MathUnit, BasicSPCUnit,
-SChartUnit, rchartunit, XBarChartUnit; //, utils, chartunit;
+SChartUnit, rchartunit, XBarChartUnit, cchartunit; //, utils, chartunit;
{$R LazStats.res}
@@ -31,6 +31,7 @@ begin
Application.CreateForm(TOS3MainFrm, OS3MainFrm);
Application.CreateForm(TRChartForm, RChartForm);
Application.CreateForm(TXBarChartForm, XBarChartForm);
+ Application.CreateForm(TCChartForm, CChartForm);
Application.Run;
end.
diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm
index 4a690afeb..7cd7590e0 100644
--- a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm
+++ b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm
@@ -16,6 +16,7 @@ object BasicSPCForm: TBasicSPCForm
Top = 0
Width = 357
Align = alLeft
+ BorderSpacing.Right = 3
BevelOuter = bvNone
ClientHeight = 438
ClientWidth = 357
@@ -211,19 +212,20 @@ object BasicSPCForm: TBasicSPCForm
end
end
object SpecsSplitter: TSplitter
- Left = 361
+ Left = 360
Height = 438
Top = 0
Width = 5
ResizeStyle = rsPattern
end
object PageControl1: TPageControl
- Left = 370
+ Left = 368
Height = 426
Top = 6
- Width = 551
+ Width = 553
ActivePage = ReportPage
Align = alClient
+ BorderSpacing.Left = 3
BorderSpacing.Top = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
@@ -232,30 +234,31 @@ object BasicSPCForm: TBasicSPCForm
object ReportPage: TTabSheet
Caption = 'Report'
ClientHeight = 398
- ClientWidth = 543
+ ClientWidth = 545
object Panel1: TPanel
Left = 6
Height = 386
Top = 6
- Width = 531
+ Width = 533
Align = alClient
BorderSpacing.Around = 6
BevelOuter = bvNone
BorderStyle = bsSingle
ClientHeight = 382
- ClientWidth = 527
+ ClientWidth = 529
TabOrder = 0
object ReportMemo: TMemo
Left = 4
Height = 374
Top = 4
- Width = 519
+ Width = 521
Align = alClient
BorderSpacing.Around = 4
BorderStyle = bsNone
Font.Height = -11
Font.Name = 'Courier New'
ParentFont = False
+ ScrollBars = ssAutoBoth
TabOrder = 0
end
end
diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas
index f3e806063..44d7f38b8 100644
--- a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas
+++ b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas
@@ -223,14 +223,13 @@ const
CL_STYLE = psDot;
SPEC_STYLE = psSolid;
var
- fn: String;
ser: TChartSeries;
- rightLabels: TListChartSource;
constLine: TConstantLine;
+ rightLabels: TListChartSource;
s: String;
begin
- fn := ExtractFileName(OS3MainFrm.FileNameEdit.Text);
rightLabels := FChartFrame.Chart.AxisList[2].Marks.Source as TListChartSource;
+ rightLabels.Clear;
FChartFrame.Clear;
FChartFrame.SetTitle(ATitle);
@@ -238,8 +237,11 @@ begin
FChartFrame.SetYTitle(AYTitle);
ser := FChartFrame.PlotXY(ptSymbols, nil, Means, Groups, nil, ADataTitle, clBlack);
- FChartFrame.Chart.BottomAxis.Marks.Source := ser.Source;
- FChartFrame.Chart.BottomAxis.Marks.style := smsLabel;
+ if Length(Groups) > 0 then
+ begin
+ FChartFrame.Chart.BottomAxis.Marks.Source := ser.Source;
+ FChartFrame.Chart.BottomAxis.Marks.style := smsLabel;
+ end;
FChartFrame.HorLine(GrandMean, clRed, psSolid, AGrandMeanTitle);
rightLabels.Add(GrandMean, GrandMean, AGrandMeanTitle);
@@ -287,6 +289,7 @@ begin
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
FChartFrame.Clear;
+ (FChartFrame.Chart.AxisList[2].Marks.Source as TListChartSource).Clear;
end;
diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm
index b44500e33..96792e479 100644
--- a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm
+++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm
@@ -1,237 +1,127 @@
-object cChartFrm: TcChartFrm
- Left = 677
- Height = 316
- Top = 312
- Width = 445
+inherited CChartForm: TCChartForm
+ Height = 420
HelpType = htKeyword
HelpKeyword = 'html/DefectnonconformitycChart.htm'
- AutoSize = True
Caption = 'Defects C Chart'
- ClientHeight = 316
- ClientWidth = 445
+ ClientHeight = 420
OnActivate = FormActivate
- OnCreate = FormCreate
- OnShow = FormShow
- Position = poMainFormCenter
- LCLVersion = '2.1.0.0'
- object Label1: TLabel
- AnchorSideLeft.Control = Owner
- AnchorSideTop.Control = Owner
- Left = 8
- Height = 15
- Top = 8
- Width = 97
- BorderSpacing.Left = 8
- BorderSpacing.Top = 8
- Caption = 'Selection Variables'
- ParentColor = False
- end
- object Label2: TLabel
- AnchorSideLeft.Control = MeasEdit
- AnchorSideTop.Control = Owner
- Left = 209
- Height = 15
- Top = 8
- Width = 120
- BorderSpacing.Top = 8
- Caption = 'Measurement Variable:'
- ParentColor = False
- end
- object VarList: TListBox
- AnchorSideLeft.Control = Owner
- AnchorSideTop.Control = Label1
- AnchorSideTop.Side = asrBottom
- AnchorSideRight.Control = SigmaOpts
- AnchorSideBottom.Control = Bevel2
- Left = 8
- Height = 242
- Top = 25
- Width = 193
- Anchors = [akTop, akLeft, akRight, akBottom]
- BorderSpacing.Left = 8
- BorderSpacing.Top = 2
- BorderSpacing.Right = 8
- Constraints.MinHeight = 220
- ItemHeight = 0
- OnClick = VarListClick
- TabOrder = 0
- end
- object MeasEdit: TEdit
- AnchorSideLeft.Control = SigmaOpts
- AnchorSideTop.Control = Label2
- AnchorSideTop.Side = asrBottom
- AnchorSideRight.Control = Owner
- AnchorSideRight.Side = asrBottom
- Left = 209
- Height = 23
- Top = 25
- Width = 228
- Anchors = [akTop, akLeft, akRight]
- BorderSpacing.Top = 2
- BorderSpacing.Right = 8
- TabOrder = 1
- Text = 'MeasEdit'
- end
- object SigmaOpts: TRadioGroup
- AnchorSideTop.Control = MeasEdit
- AnchorSideTop.Side = asrBottom
- AnchorSideRight.Control = Owner
- AnchorSideRight.Side = asrBottom
- Left = 209
- Height = 118
- Top = 80
- Width = 228
- Anchors = [akTop, akRight]
- AutoFill = True
- AutoSize = True
- BorderSpacing.Top = 32
- BorderSpacing.Right = 8
- Caption = 'No. of Sigma Units for UCL and LCL'
- ChildSizing.LeftRightSpacing = 6
- ChildSizing.TopBottomSpacing = 6
- ChildSizing.HorizontalSpacing = 5
- ChildSizing.VerticalSpacing = 2
- ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
- ChildSizing.EnlargeVertical = crsHomogenousChildResize
- ChildSizing.ShrinkHorizontal = crsScaleChilds
- ChildSizing.ShrinkVertical = crsScaleChilds
- ChildSizing.Layout = cclTopToBottomThenLeftToRight
- ChildSizing.ControlsPerLine = 4
- ClientHeight = 98
- ClientWidth = 224
- ItemIndex = 0
- Items.Strings = (
- '3 Sigma (Default)'
- '2 Sigma'
- '1 Sigma'
- 'X Sigmas where X = '
- )
- TabOrder = 2
- object Label3: TLabel
- Left = 138
- Height = 19
- Top = 6
- Width = 80
- Caption = ' '
- ParentColor = False
+ inherited SpecsPanel: TPanel
+ Height = 420
+ Width = 440
+ ClientHeight = 420
+ ClientWidth = 440
+ inherited ButtonPanel: TPanel
+ Top = 378
+ Width = 440
+ ClientWidth = 440
+ inherited CloseBtn: TButton
+ Left = 385
+ end
+ inherited ComputeBtn: TButton
+ Left = 301
+ end
+ inherited ResetBtn: TButton
+ Left = 239
+ end
+ inherited HelpBtn: TButton
+ Left = 188
+ end
+ inherited Bevel1: TBevel
+ Width = 432
+ end
end
- object Label4: TLabel
- Left = 138
- Height = 19
- Top = 27
- Width = 80
- Caption = ' '
- ParentColor = False
+ inherited VarList: TListBox
+ Height = 345
+ Width = 216
end
- object Label5: TLabel
- Left = 138
- Height = 19
- Top = 48
- Width = 80
- Caption = ' '
- ParentColor = False
+ inherited GroupLabel: TLabel
+ Left = 232
+ Visible = False
end
- object XSigmaEdit: TEdit
- Left = 138
- Height = 23
- Top = 69
- Width = 80
- Alignment = taRightJustify
- TabOrder = 2
- Text = 'XSigmaEdit'
+ inherited GroupEdit: TEdit
+ Left = 232
+ Width = 208
+ Visible = False
end
- end
- object Bevel2: TBevel
- AnchorSideTop.Control = Panel1
- AnchorSideRight.Control = Owner
- AnchorSideRight.Side = asrBottom
- AnchorSideBottom.Control = Panel1
- Left = 0
- Height = 8
- Top = 267
- Width = 445
- Anchors = [akLeft, akRight, akBottom]
- Shape = bsBottomLine
- end
- object Panel1: TPanel
- Left = 8
- Height = 25
- Top = 283
- Width = 429
- Align = alBottom
- AutoSize = True
- BorderSpacing.Around = 8
- BevelOuter = bvNone
- ClientHeight = 25
- ClientWidth = 429
- TabOrder = 3
- object ResetBtn: TButton
- AnchorSideLeft.Control = Panel1
- AnchorSideTop.Control = Panel1
- AnchorSideRight.Control = ComputeBtn
- Left = 228
- Height = 25
- Top = 0
- Width = 54
- Anchors = [akTop, akRight]
- AutoSize = True
- BorderSpacing.Right = 8
- Caption = 'Reset'
- OnClick = ResetBtnClick
- TabOrder = 1
+ inherited MeasLabel: TLabel
+ Left = 232
end
- object ComputeBtn: TButton
- AnchorSideLeft.Control = Panel1
- AnchorSideTop.Control = Panel1
- AnchorSideRight.Control = CloseBtn
- Left = 290
- Height = 25
- Top = 0
- Width = 76
- Anchors = [akTop, akRight]
- AutoSize = True
- BorderSpacing.Right = 8
- Caption = 'Compute'
- OnClick = ComputeBtnClick
- TabOrder = 2
+ inherited MeasEdit: TEdit
+ Left = 232
+ Width = 208
end
- object HelpBtn: TButton
- Tag = 141
- AnchorSideLeft.Control = Panel1
- AnchorSideTop.Control = ResetBtn
- AnchorSideRight.Control = ResetBtn
- Left = 169
- Height = 25
- Top = 0
- Width = 51
- Anchors = [akTop, akRight]
- AutoSize = True
- BorderSpacing.Right = 8
- Caption = 'Help'
- OnClick = HelpBtnClick
- TabOrder = 0
+ inherited Bevel2: TBevel
+ Left = 209
end
- object CloseBtn: TButton
- AnchorSideLeft.Control = Panel1
- AnchorSideTop.Control = Panel1
- AnchorSideRight.Control = Panel1
+ object SigmaOptns: TRadioGroup[8]
+ AnchorSideLeft.Control = MeasEdit
+ AnchorSideTop.Control = MeasEdit
+ AnchorSideTop.Side = asrBottom
+ AnchorSideRight.Control = SpecsPanel
AnchorSideRight.Side = asrBottom
- Left = 374
- Height = 25
- Top = 0
- Width = 55
- Anchors = [akTop, akRight]
- AutoSize = True
- Caption = 'Close'
- ModalResult = 11
- TabOrder = 3
+ Left = 232
+ Height = 128
+ Top = 128
+ Width = 208
+ Anchors = [akTop, akLeft, akRight]
+ AutoFill = True
+ BorderSpacing.Top = 32
+ BorderSpacing.Bottom = 8
+ Caption = 'No. of Sigma Units for UCL and LCL'
+ ChildSizing.LeftRightSpacing = 12
+ ChildSizing.TopBottomSpacing = 6
+ ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
+ ChildSizing.EnlargeVertical = crsHomogenousChildResize
+ ChildSizing.ShrinkHorizontal = crsScaleChilds
+ ChildSizing.ShrinkVertical = crsScaleChilds
+ ChildSizing.Layout = cclLeftToRightThenTopToBottom
+ ChildSizing.ControlsPerLine = 1
+ ClientHeight = 108
+ ClientWidth = 204
+ ItemIndex = 0
+ Items.Strings = (
+ '3 Sigma (default)'
+ '2 Sigma'
+ '1 Sigma'
+ 'x Sigmas with x = '
+ )
+ TabOrder = 4
+ object XSigmaEdit: TEdit
+ AnchorSideRight.Control = SigmaOptns
+ AnchorSideRight.Side = asrBottom
+ AnchorSideBottom.Side = asrBottom
+ Left = 128
+ Height = 23
+ Top = 80
+ Width = 64
+ Alignment = taRightJustify
+ Anchors = [akLeft, akRight, akBottom]
+ TabOrder = 0
+ Text = 'XSigmaEdit'
+ end
end
end
- object Bevel1: TBevel
- Left = 4
- Height = 23
- Top = 290
- Width = 25
- Shape = bsSpacer
+ inherited SpecsSplitter: TSplitter
+ Left = 443
+ Height = 420
+ end
+ inherited PageControl1: TPageControl
+ Left = 451
+ Height = 408
+ Width = 470
+ inherited ReportPage: TTabSheet
+ ClientHeight = 380
+ ClientWidth = 462
+ inherited Panel1: TPanel
+ Height = 368
+ Width = 450
+ ClientHeight = 364
+ ClientWidth = 446
+ inherited ReportMemo: TMemo
+ Height = 356
+ Width = 438
+ end
+ end
+ end
end
end
diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas
index 6411806b3..be045da87 100644
--- a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas
+++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas
@@ -5,162 +5,75 @@ unit CChartUnit;
interface
uses
- Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
- StdCtrls, ExtCtrls, Buttons,
- MainUnit, Globals, DataProcs, OutputUnit, BlankFrmUnit, ContextHelpUnit;
+ Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls,
+ StdCtrls, BasicSPCUnit;
type
- { TcChartFrm }
+ { TCChartForm }
- TcChartFrm = class(TForm)
- Bevel1: TBevel;
- Bevel2: TBevel;
- ComputeBtn: TButton;
- HelpBtn: TButton;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Panel1: TPanel;
- ResetBtn: TButton;
- CloseBtn: TButton;
+ TCChartForm = class(TBasicSPCForm)
+ SigmaOptns: TRadioGroup;
XSigmaEdit: TEdit;
- MeasEdit: TEdit;
- Label1: TLabel;
- Label2: TLabel;
- VarList: TListBox;
- SigmaOpts: TRadioGroup;
- procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure HelpBtnClick(Sender: TObject);
- procedure VarListClick(Sender: TObject);
- procedure ResetBtnClick(Sender: TObject);
- private
- { private declarations }
- FAutoSized: Boolean;
- procedure PlotMeans(var Means: DblDyneVec; NoGrps: integer;
- UCL, LCL, GrandMean: double);
- function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
- public
- { public declarations }
- end;
+ protected
+ procedure Compute; override;
+ procedure Reset; override;
+ function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override;
+
+ end;
var
- cChartFrm: TcChartFrm;
+ CChartForm: TCChartForm;
implementation
+{$R *.lfm}
+
uses
- Math;
+ Math,
+ Globals, MainUnit, DataProcs;
-{ TcChartFrm }
-procedure TcChartFrm.ResetBtnClick(Sender: TObject);
+{ TCChartForm }
+
+procedure TCChartForm.Compute;
var
- i: integer;
-begin
- VarList.Clear;
- MeasEdit.Text := '';
- for i := 1 to NoVariables do
- VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
-end;
-
-procedure TcChartFrm.FormActivate(Sender: TObject);
-var
- w: Integer;
-begin
- if FAutoSized then
- exit;
-
- w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
- HelpBtn.Constraints.MinWidth := w;
- ResetBtn.Constraints.MinWidth := w;
- ComputeBtn.Constraints.MinWidth := w;
- CloseBtn.Constraints.MinWidth := w;
-
- VarList.Constraints.MinWidth := SigmaOpts.Width * 3 div 4;
-
- Constraints.MinWidth := Width;
- Constraints.MinHeight := Height;
-
- FAutoSized := true;
-end;
-
-procedure TcChartFrm.FormCreate(Sender: TObject);
-begin
- Assert(OS3MainFrm <> nil);
- if BlankFrm = nil then
- Application.CreateForm(TBlankFrm, BlankFrm);
-end;
-
-procedure TcChartFrm.FormShow(Sender: TObject);
-begin
- ResetBtnClick(self);
-end;
-
-procedure TcChartFrm.HelpBtnClick(Sender: TObject);
-begin
- if ContextHelpForm = nil then
- Application.CreateForm(TContextHelpForm, ContextHelpForm);
- ContextHelpForm.HelpMessage((Sender as TButton).tag);
-end;
-
-procedure TcChartFrm.ComputeBtnClick(Sender: TObject);
-var
- i, MeasVar: integer;
- X, size, UCL, LCL, Sigma: double;
- GrandMean, meanc, stddevc: double;
- means: DblDyneVec;
- cellstring: string;
- ColNoSelected: IntDyneVec;
- NoSelected: integer;
- msg: String;
- C: TWinControl;
+ i: Integer;
+ ColNoSelected: IntDyneVec = nil;
+ means: DblDyneVec = nil;
+ X: Double;
+ meanC, stdDevC, UCL, LCL, sigma, grandMean: Double;
+ numData: Integer;
lReport: TStrings;
begin
- if not Validate(msg, C) then
- begin
- C.SetFocus;
- MessageDlg(msg, mtError, [mbOK], 0);
- exit;
- end;
-
SetLength(ColNoSelected,1);
- MeasVar := 0;
- for i := 1 to NoVariables do
- begin
- cellstring := OS3MainFrm.DataGrid.Cells[i,0];
- if cellstring = MeasEdit.Text then MeasVar := i;
- end;
- NoSelected := 1;
ColNoSelected[0] := MeasVar;
- case SigmaOpts.ItemIndex of
- 0: Sigma := 3.0;
+ case SigmaOptns.ItemIndex of
+ 0: sigma := 3.0;
1: sigma := 2.0;
- 2: Sigma := 1.0;
- 3: Sigma := StrToFloat(XSigmaEdit.Text);
+ 2: sigma := 1.0;
+ 3: sigma := StrToFloat(XSigmaEdit.Text);
end;
SetLength(means, NoCases + 1);
- GrandMean := 0.0;
- size := 0;
-
+ grandMean := 0.0;
+ numData := 0;
for i := 1 to NoCases do
begin
- if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
- X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[MeasVar,i]));
- means[i] := X;
- GrandMean := GrandMean + X;
- size := size + 1;
+ if not GoodRecord(i, Length(ColNoSelected), ColNoSelected) then continue;
+ X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[MeasVar, i]));
+ means[i-1] := X;
+ grandMean := grandMean + X;
+ inc(numData);
end;
+ SetLength(means, numData);
- meanc := GrandMean / size;
- stddevc := sqrt(meanc);
- UCL := meanc + Sigma * stddevc;
- LCL := meanc - Sigma * stddevc;
+ meanc := grandMean / numData;
+ stdDevc := sqrt(meanc);
+ UCL := meanc + sigma * stddevc;
+ LCL := meanc - sigma * stddevc;
// printed results
lReport := TStringList.Create;
@@ -168,190 +81,97 @@ begin
lReport.Add('DEFECTS c CONTROL CHART RESULTS');
lReport.Add('');
lReport.Add('Sample Number of ');
- lReport.Add(' Nonconformities');
- lReport.Add('------ ----------------');
+ lReport.Add(' Nonconformities');
+ lReport.Add('------ ---------------');
for i := 1 to NoCases do
- lReport.Add(' %3d %8.2f', [i, means[i]]);
+ lReport.Add('%6d %15.2f', [i, means[i]]);
+ lReport.Add('');
lReport.Add('Total Nonconformities: %8.3f', [GrandMean]);
- lReport.Add('No. of samples: %8d', [NoCases]);
+ lReport.Add('No. of samples: %8d', [numData]); //NoCases]);
lReport.Add('Poisson mean and variance: %8.3f', [meanc]);
lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]);
- DisplayReport(lReport);
+
+ ReportMemo.Lines.Assign(lReport);
finally
lReport.Free;
end;
- // show graph
- PlotMeans(means, NoCases, UCL, LCL, meanc);
+ // Show graph
+ PlotMeans(
+ Format('Defect Control C Chart for "%s"', [GetFileName]),
+ 'Sample', MeasEdit.Text, 'Data', 'Mean',
+ nil, means,
+ UCL, LCL, meanc,
+ NaN, NaN, NaN
+ );
- means := nil;
- ColNoSelected := nil;
+ //PlotMeans(means, NoCases, UCL, LCL, meanc);
end;
-procedure TcChartFrm.VarListClick(Sender: TObject);
+procedure TCChartForm.FormActivate(Sender: TObject);
var
- index: integer;
+ w: Integer;
begin
- index := VarList.ItemIndex;
- if index > -1 then
- begin
- MeasEdit.Text := VarList.Items[index];
- VarList.Items.Delete(index);
+ w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
+ HelpBtn.Constraints.MinWidth := w;
+ ResetBtn.Constraints.MinWidth := w;
+ ComputeBtn.Constraints.MinWidth := w;
+ CloseBtn.Constraints.MinWidth := w;
+
+ DisableAutoSizing;
+ try
+ SigmaOptns.AnchorSideRight.Control := nil;
+ VarList.Constraints.MinWidth := VarListLabel.Width;
+ SpecsPanel.Constraints.MinWidth := Max(
+ CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around,
+ SigmaOptns.Width * 2 + VarList.BorderSpacing.Right + VarList.BorderSpacing.Left
+ );
+ Constraints.MinHeight := SigmaOptns.Top + SigmaOptns.Height + SigmaOptns.BorderSpacing.Bottom + ButtonPanel.Height;
+
+ SigmaOptns.AnchorSideRight.Control := MeasEdit;
+ SigmaOptns.AnchorSideRight.Side := asrBottom;
+ finally
+ EnableAutoSizing;
end;
end;
-procedure TcChartFrm.PlotMeans(var means: DblDyneVec; NoGrps: integer; UCL,
- LCL, GrandMean: double);
-var
- i, xpos, ypos, hleft, hright, vtop, vbottom, imagewide : integer;
- vhi, hwide, offset, strhi : integer;
- imagehi, maxval, minval, valincr, Yvalue : double;
- Title : string;
+
+procedure TCChartForm.Reset;
begin
- maxval := -10000.0;
- minval := 10000.0;
- for i := 1 to NoGrps do
- begin
- if means[i] > maxval then maxval := means[i];
- if means[i] < minval then minval := means[i];
- end;
- if UCL > maxval then maxval := UCL;
- if LCL < minval then minval := LCL;
- BlankFrm.Image1.Canvas.Clear;
- BlankFrm.Show;
- Title := 'DEFECT CONTROL (c) CHART FOR : ' + OS3MainFrm.FileNameEdit.Text;
- BlankFrm.Caption := Title;
- imagewide := BlankFrm.Image1.Width;
- imagehi := BlankFrm.Image1.Height;
- vtop := 20;
- vbottom := round(imagehi) - 80;
- vhi := vbottom - vtop;
- hleft := 100;
- hright := imagewide - 80;
- hwide := hright - hleft;
-
- BlankFrm.Image1.Canvas.Brush.Color := clLtGray;
- BlankFrm.Image1.Canvas.FillRect(0, 0, BlankFrm.Image1.Width, BlankFrm.Image1.Height);
-
- // Draw chart border
- BlankFrm.Image1.Canvas.Pen.Color := clBlack;
- BlankFrm.Image1.Canvas.Brush.Color := clWhite;
- BlankFrm.Image1.Canvas.Rectangle(hleft,vtop-10,hleft+hwide,vtop+vhi+10);
-
- // draw Grand Mean
- ypos := round(vhi * ( (maxval - GrandMean) / (maxval - minval)));
- ypos := ypos + vtop;
- xpos := hleft;
- BlankFrm.Image1.Canvas.Pen.Color := clRed;
- BlankFrm.Image1.Canvas.Brush.Style := bsClear;
- BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
- xpos := hright;
- BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
- Title := 'MEAN';
- strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
- ypos := ypos - strhi div 2;
- BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
-
- // draw horizontal axis
- BlankFrm.Image1.Canvas.Pen.Color := clBlack;
- BlankFrm.Image1.Canvas.MoveTo(hleft,vbottom + 20);
- BlankFrm.Image1.Canvas.LineTo(hright,vbottom + 20);
- for i := 1 to NoGrps do
- begin
- ypos := vbottom + 10;
- xpos := round((hwide / NoGrps)* i + hleft);
- BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
- ypos := ypos + 10;
- BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
- Title := format('%d',[i]);
- offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
- strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
- xpos := xpos - offset;
- ypos := ypos + strhi;
- BlankFrm.Image1.Canvas.Pen.Color := clBlack;
- BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
- xpos := 10;
- BlankFrm.Image1.Canvas.TextOut(xpos,ypos,'GROUPS:');
- end;
-
- // Draw vertical axis
- valincr := (maxval - minval) / 10.0;
- for i := 1 to 11 do
- begin
- Title := format('%8.2f',[maxval - ((i-1)*valincr)]);
- strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
- xpos := 10;
- Yvalue := maxval - (valincr * (i-1));
- ypos := round(vhi * ( (maxval - Yvalue) / (maxval - minval)));
- ypos := ypos + vtop - strhi div 2;
- BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
- end;
-
- // draw lines for means of the groups
- ypos := round(vhi * ( (maxval - means[1]) / (maxval - minval)));
- ypos := ypos + vtop;
- xpos := round((hwide / NoGrps) + hleft);
- BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
- BlankFrm.Image1.Canvas.Pen.Color := clBlack;
- for i := 2 to NoGrps do
- begin
- ypos := round(vhi * ( (maxval - means[i]) / (maxval - minval)));
- ypos := ypos + vtop;
- xpos := round((hwide / NoGrps)* i + hleft);
- BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
- end;
-
- // Draw upper and lower confidence intervals
- ypos := round(vhi * ( (maxval - UCL) / (maxval - minval)));
- ypos := ypos + vtop;
- xpos := hleft;
- BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
- xpos := hright;
- BlankFrm.Image1.Canvas.Pen.Color := clRed;
- BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
- Title := 'UCL';
- strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
- ypos := ypos - strhi div 2;
- BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
-
- ypos := round(vhi * ( (maxval - LCL) / (maxval - minval)));
- ypos := ypos + vtop;
- xpos := hleft;
- BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
- xpos := hright;
- BlankFrm.Image1.Canvas.Pen.Color := clRed;
- BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
- Title := 'LCL';
- strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
- ypos := ypos - strhi div 2;
- BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
+ inherited;
+ XSigmaEdit.Clear;
end;
-function TCChartFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
+
+function TCChartForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var
x: Double;
begin
+ Result := inherited;
+ if not Result then
+ exit;
+
Result := false;
- if MeasEdit.Text = '' then
+ if SigmaOptns.ItemIndex = -1 then
begin
- AMsg := 'Measurement variable not selected.';
- AControl := MeasEdit;
+ AMsg := 'Number of sigma units for UCL and LCL not specified.';
+ AControl := SigmaOptns;
exit;
end;
- if SigmaOpts.ItemIndex = 3 then
+ if SigmaOptns.ItemIndex = 3 then
begin
- if XSigmaEdit.Text = '' then
+ if (XSigmaEdit.Text = '') then
begin
- AMsg := 'X sigma not specified.';
+ AMsg := 'User-defined sigma units missing.';
AControl := XSigmaEdit;
exit;
end;
if not TryStrToFloat(XSigmaEdit.Text, x) then
begin
- AMsg := 'X sigma is not a valid number.';
+ AMsg := 'No valid number given for sser-defined sigma units.';
AControl := XSigmaEdit;
exit;
end;
@@ -360,8 +180,5 @@ begin
Result := true;
end;
-initialization
- {$I cchartunit.lrs}
-
end.
diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm
index b0cc0309f..95520a265 100644
--- a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm
+++ b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm
@@ -7,7 +7,6 @@ inherited XBarChartForm: TXBarChartForm
OnActivate = FormActivate
inherited SpecsPanel: TPanel
Width = 475
- BorderSpacing.Right = 3
ClientWidth = 475
inherited ButtonPanel: TPanel
Width = 475
@@ -207,7 +206,6 @@ inherited XBarChartForm: TXBarChartForm
inherited PageControl1: TPageControl
Left = 486
Width = 435
- BorderSpacing.Left = 3
inherited ReportPage: TTabSheet
ClientWidth = 427
inherited Panel1: TPanel
diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas
index 5dd7e4df0..685615002 100644
--- a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas
+++ b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas
@@ -182,7 +182,7 @@ begin
lReport.Free;
end;
- // show graph
+ // Show graph
PlotMeans(
Format('x̄ chart for "%s"', [GetFileName]),
GroupEdit.Text, MeasEdit.Text, 'Group means', 'Grand mean',
diff --git a/applications/lazstats/source/forms/mainunit.pas b/applications/lazstats/source/forms/mainunit.pas
index 787d17c93..202d17bc5 100644
--- a/applications/lazstats/source/forms/mainunit.pas
+++ b/applications/lazstats/source/forms/mainunit.pas
@@ -510,7 +510,7 @@ uses
BinomialUnit, KendallTauUnit, KaplanMeierUnit,
// Statistical process control
- XBarChartUnit, RChartUnit, SChartUnit, CUMSUMUNIT, CCHARTUNIT,
+ XBarChartUnit, RChartUnit, SChartUnit, CUMSUMUNIT, CChartUnit,
PChartUnit, UChartUnit,
CorSimUnit,
@@ -2160,9 +2160,9 @@ end;
// Menu "Analysis" > "Statistical Process Control" > "Defect (nonconformity) c Chart"
procedure TOS3MainFrm.mnuAnalysisSPC_CChartClick(Sender: TObject);
begin
- if CChartFrm = nil then
- Application.CreateForm(TCChartFrm, CChartFrm);
- CChartFrm.ShowModal;
+ if CChartForm = nil then
+ Application.CreateForm(TCChartForm, CChartForm);
+ CChartForm.ShowModal;
end;
// Menu "Analysis" > "Financial" > "Sum of years digits depreciation"
diff --git a/applications/lazstats/source/frames/chartframeunit.lfm b/applications/lazstats/source/frames/chartframeunit.lfm
index 546a629ec..6e2284476 100644
--- a/applications/lazstats/source/frames/chartframeunit.lfm
+++ b/applications/lazstats/source/frames/chartframeunit.lfm
@@ -6,8 +6,8 @@ object ChartFrame: TChartFrame
ClientHeight = 403
ClientWidth = 620
TabOrder = 0
- DesignLeft = 353
- DesignTop = 156
+ DesignLeft = 518
+ DesignTop = 150
object Chart: TChart
Left = 0
Height = 403