diff --git a/applications/lazstats/docs/HelpNDoc/LazStats.hnd b/applications/lazstats/docs/HelpNDoc/LazStats.hnd index b5b9c3062..6bf9844cd 100644 Binary files a/applications/lazstats/docs/HelpNDoc/LazStats.hnd and b/applications/lazstats/docs/HelpNDoc/LazStats.hnd differ diff --git a/applications/lazstats/docs/chm/LazStats.chm b/applications/lazstats/docs/chm/LazStats.chm index 4f3d68b23..55713c76c 100644 Binary files a/applications/lazstats/docs/chm/LazStats.chm and b/applications/lazstats/docs/chm/LazStats.chm differ diff --git a/applications/lazstats/source/forms/analysis/descriptive/plotxyunit.pas b/applications/lazstats/source/forms/analysis/descriptive/plotxyunit.pas index 0c67a8116..b48799542 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/plotxyunit.pas +++ b/applications/lazstats/source/forms/analysis/descriptive/plotxyunit.pas @@ -50,7 +50,7 @@ type private { private declarations } FAutoSized: Boolean; - procedure plotxy(VAR Xpoints : DblDyneVec; + procedure PlotXY(VAR Xpoints : DblDyneVec; VAR Ypoints : DblDyneVec; VAR UpConf : DblDyneVec; VAR LowConf : DblDyneVec; @@ -112,19 +112,22 @@ var index: integer; begin index := VarList.ItemIndex; - if index > -1 then + if (index > -1) and (XEdit.Text = '') then begin XEdit.Text := VarList.Items[index]; VarList.Items.Delete(index); + UpdateBtnStates; end; - UpdateBtnStates; end; procedure TPlotXYFrm.XOutBtnClick(Sender: TObject); begin - VarList.Items.Add(XEdit.Text); - XEdit.Text := ''; - UpdateBtnStates; + if XEdit.Text <> '' then + begin + VarList.Items.Add(XEdit.Text); + XEdit.Text := ''; + UpdateBtnStates; + end; end; procedure TPlotXYFrm.YInBtnClick(Sender: TObject); @@ -132,19 +135,22 @@ var index: integer; begin index := VarList.ItemIndex; - if index > -1 then + if (index > -1) and (YEdit.Text = '') then begin YEdit.Text := VarList.Items[index]; VarList.Items.Delete(index); + UpdateBtnStates; end; - UpdateBtnStates; end; procedure TPlotXYFrm.YOutBtnClick(Sender: TObject); begin - VarList.Items.Add(YEdit.Text); - YEdit.Text := ''; - UpdateBtnStates; + if YEdit.Text <> '' then + begin + VarList.Items.Add(YEdit.Text); + YEdit.Text := ''; + UpdateBtnStates; + end; end; procedure TPlotXYFrm.FormShow(Sender: TObject); @@ -454,7 +460,7 @@ begin BlankFrm.Image1.Canvas.MoveTo(xpos,ypos); ypos := ypos + 10; BlankFrm.Image1.Canvas.LineTo(xpos,ypos); - Title := format('%6.2f',[Xvalue]); + Title := format('%.2f',[Xvalue]); offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2; xpos := xpos - offset; BlankFrm.Image1.Canvas.Pen.Color := clBlack; diff --git a/applications/lazstats/source/forms/analysis/descriptive/smoothdataunit.lfm b/applications/lazstats/source/forms/analysis/descriptive/smoothdataunit.lfm index ea9b7a912..e918549e4 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/smoothdataunit.lfm +++ b/applications/lazstats/source/forms/analysis/descriptive/smoothdataunit.lfm @@ -160,12 +160,12 @@ object DataSmoothingForm: TDataSmoothingForm Left = 8 Height = 19 Top = 316 - Width = 188 + Width = 122 Anchors = [akLeft, akBottom] BorderSpacing.Left = 8 BorderSpacing.Top = 8 BorderSpacing.Bottom = 4 - Caption = 'Repeat Smoothing No. Times = ' + Caption = 'Execute smoothing' TabOrder = 7 end object RepeatEdit: TEdit @@ -173,7 +173,7 @@ object DataSmoothingForm: TDataSmoothingForm AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = RepeatChk AnchorSideTop.Side = asrCenter - Left = 204 + Left = 138 Height = 23 Top = 314 Width = 32 @@ -212,4 +212,17 @@ object DataSmoothingForm: TDataSmoothingForm ParentColor = False WordWrap = True end + object Label3: TLabel + AnchorSideLeft.Control = RepeatEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = RepeatEdit + AnchorSideTop.Side = asrCenter + Left = 178 + Height = 15 + Top = 318 + Width = 29 + BorderSpacing.Left = 8 + Caption = 'times' + ParentColor = False + end end diff --git a/applications/lazstats/source/forms/analysis/descriptive/smoothdataunit.pas b/applications/lazstats/source/forms/analysis/descriptive/smoothdataunit.pas index 9d01f0b28..d057302d4 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/smoothdataunit.pas +++ b/applications/lazstats/source/forms/analysis/descriptive/smoothdataunit.pas @@ -15,6 +15,7 @@ type TDataSmoothingForm = class(TForm) Bevel1: TBevel; + Label3: TLabel; Memo1: TLabel; RepeatEdit: TEdit; RepeatChk: TCheckBox; @@ -66,51 +67,66 @@ end; procedure TDataSmoothingForm.ComputeBtnClick(Sender: TObject); var - DataPts, OutPts : DblDyneVec; - avalue, avg : double; - N, Reps, i, j, VarCol : integer; - VarLabel, strvalue : string; + DataPts, OutPts: DblDyneVec; + N, Reps, i, j, VarCol: integer; + VarLabel, strValue: string; begin - N := NoCases; - SetLength(DataPts,N); - SetLength(OutPts,N); - Reps := StrToInt(RepeatEdit.Text); - Varlabel := SelectedEdit.Text; - for i := 1 to NoVariables do - if VarLabel = OS3MainFrm.DataGrid.Cells[i,0] then VarCol := i; - for i := 0 to N - 1 do - begin - avalue := StrToFloat(OS3MainFrm.DataGrid.Cells[VarCol,i+1]); - DataPts[i] := avalue; - end; + if SelectedEdit.Text = '' then + begin + MessageDlg('No variable selected.', mtError, [mbOk], 0); + exit; + end; - // repeat smoothing for number of times elected - OutPts[0] := DataPts[0]; - OutPts[N-1] := DataPts[N-1]; - for j := 1 to Reps do - begin - for i := 1 to N - 2 do - begin - avg := (DataPts[i-1] + DataPts[i] + DataPts[i+1]) / 3.0; - OutPts[i] := avg; - end; - if j < reps then - for i := 0 to N - 1 do DataPts[i] := OutPts[i]; - end; - // create a new variable and copy smoothed data into it - strvalue := 'Smoothed' + VarLabel; - DictionaryFrm.NewVar(NoVariables+1); - DictionaryFrm.DictGrid.Cells[1,NoVariables] := strvalue; - OS3MainFrm.DataGrid.Cells[NoVariables,0] := strvalue; - for i := 0 to N - 1 do - begin - strvalue := format('%9.3f',[OutPts[i]]); - OS3MainFrm.DataGrid.Cells[NoVariables,i+1] := strvalue; - end; + if RepeatChk.Checked then + begin + if RepeatEdit.Text = '' then + begin + MessageDlg('Repeat count not specified.', mtError, [mbOK], 0); + exit; + end; + if not TryStrToInt(RepeatEdit.Text, Reps) and (Reps < 1) then + begin + MessageDlg('Repeat count must be >= 1.', mtError, [mbOK], 0); + exit; + end; + end else + Reps := 1; - // clean up - OutPts := nil; - DataPts := nil; + N := NoCases; + SetLength(DataPts,N); + SetLength(OutPts,N); + + Varlabel := SelectedEdit.Text; + for i := 1 to NoVariables do + if VarLabel = OS3MainFrm.DataGrid.Cells[i,0] then VarCol := i; + for i := 0 to N - 1 do + DataPts[i] := StrToFloat(OS3MainFrm.DataGrid.Cells[VarCol,i+1]); + + // repeat smoothing for number of times elected + OutPts[0] := DataPts[0]; + OutPts[N-1] := DataPts[N-1]; + for j := 1 to Reps do + begin + for i := 1 to N - 2 do + OutPts[i] := (DataPts[i-1] + DataPts[i] + DataPts[i+1]) / 3.0; + if j < reps then + for i := 0 to N - 1 do DataPts[i] := OutPts[i]; + end; + + // create a new variable and copy smoothed data into it + if Reps = 1 then + strvalue := Format('%s_Smoothed', [VarLabel]) + else + strvalue := Format('%s_Smoothed_%dx', [VarLabel, Reps]); + DictionaryFrm.NewVar(NoVariables+1); + DictionaryFrm.DictGrid.Cells[1,NoVariables] := strvalue; + OS3MainFrm.DataGrid.Cells[NoVariables,0] := strvalue; + for i := 0 to N - 1 do + OS3MainFrm.DataGrid.Cells[NoVariables,i+1] := Format('%0.3f', [OutPts[i]]); + + // clean up + OutPts := nil; + DataPts := nil; end; procedure TDataSmoothingForm.FormActivate(Sender: TObject); diff --git a/applications/lazstats/source/forms/analysis/descriptive/xvsmultyunit.pas b/applications/lazstats/source/forms/analysis/descriptive/xvsmultyunit.pas index a69b76986..799869a04 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/xvsmultyunit.pas +++ b/applications/lazstats/source/forms/analysis/descriptive/xvsmultyunit.pas @@ -64,7 +64,7 @@ var implementation uses - Math; + Math, Utils; { TXvsMultYForm } @@ -439,7 +439,14 @@ begin end; procedure TXvsMultYForm.UpdateBtnStates; +var + lSelected: Boolean; begin + lSelected := AnySelected(VarList); + XInBtn.Enabled := lSelected and (XEdit.Text = ''); + YInBtn.Enabled := lSelected; + xOutBtn.Enabled := (XEdit.Text <> ''); + YOutBtn.Enabled := AnySelected(YBox); end; initialization