diff --git a/components/tachart/demo/fit/Main.lfm b/components/tachart/demo/fit/Main.lfm index 918c8a1c73..883733025c 100644 --- a/components/tachart/demo/fit/Main.lfm +++ b/components/tachart/demo/fit/Main.lfm @@ -13,18 +13,18 @@ object frmMain: TfrmMain Left = 8 Height = 527 Top = 8 - Width = 400 + Width = 440 Align = alLeft BorderSpacing.Around = 8 BevelOuter = bvNone ClientHeight = 527 - ClientWidth = 400 + ClientWidth = 440 TabOrder = 0 object PageControl1: TPageControl Left = 0 Height = 527 Top = 0 - Width = 400 + Width = 440 ActivePage = TabSheet1 Align = alClient TabIndex = 0 @@ -32,18 +32,18 @@ object frmMain: TfrmMain object TabSheet1: TTabSheet Caption = 'Preparation' ClientHeight = 499 - ClientWidth = 392 + ClientWidth = 432 object gbDataGeneration: TGroupBox Left = 4 Height = 157 Top = 4 - Width = 384 + Width = 424 Align = alTop AutoSize = True BorderSpacing.Around = 4 Caption = ' Data generation ' ClientHeight = 137 - ClientWidth = 380 + ClientWidth = 420 Font.Style = [fsBold] ParentFont = False TabOrder = 0 @@ -51,7 +51,7 @@ object frmMain: TfrmMain AnchorSideTop.Control = edNoiseY AnchorSideRight.Control = cbTestFunction AnchorSideRight.Side = asrBottom - Left = 349 + Left = 389 Height = 22 Hint = 'Export data to verify fit with other software' Top = 31 @@ -105,7 +105,7 @@ object frmMain: TfrmMain Height = 23 Hint = 'Select a dataset for fitting' Top = 4 - Width = 272 + Width = 312 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 16 BorderSpacing.Top = 4 @@ -208,7 +208,7 @@ object frmMain: TfrmMain Left = 8 Height = 8 Top = 89 - Width = 364 + Width = 404 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 BorderSpacing.Right = 8 @@ -240,11 +240,11 @@ object frmMain: TfrmMain Left = 93 Height = 30 Top = 97 - Width = 287 + Width = 327 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 16 BorderSpacing.Bottom = 4 - Caption = 'x, y : two columns, separator semicolon or tab'#13#10'dy: in optional third column' + Caption = 'x, y : two columns, separated by comma, semicolon or tab'#13#10'dy: in optional third column' ParentColor = False ParentFont = False end @@ -253,36 +253,36 @@ object frmMain: TfrmMain Left = 4 Height = 330 Top = 169 - Width = 384 + Width = 424 Align = alClient BorderSpacing.Left = 4 BorderSpacing.Top = 8 BorderSpacing.Right = 4 Caption = ' Fitting ' ClientHeight = 310 - ClientWidth = 380 + ClientWidth = 420 Font.Style = [fsBold] ParentFont = False TabOrder = 1 object gbFitRange: TGroupBox - AnchorSideLeft.Control = GroupBox1 - AnchorSideTop.Control = GroupBox1 + AnchorSideLeft.Control = gbFixedParams + AnchorSideTop.Control = gbFixedParams AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = GroupBox1 + AnchorSideRight.Control = gbFixedParams AnchorSideRight.Side = asrBottom Left = 14 Height = 109 Top = 151 - Width = 352 + Width = 392 Anchors = [akTop, akLeft, akRight] AutoSize = True BorderSpacing.Top = 16 Caption = 'Fit range' ClientHeight = 89 - ClientWidth = 348 + ClientWidth = 388 Font.Style = [fsBold] ParentFont = False - TabOrder = 0 + TabOrder = 3 object cbFitRangeUseMin: TCheckBox AnchorSideLeft.Control = gbFitRange AnchorSideTop.Control = gbFitRange @@ -309,7 +309,7 @@ object frmMain: TfrmMain Caption = 'Use maximum' OnClick = cbFitRangeUseMaxClick ParentFont = False - TabOrder = 1 + TabOrder = 2 end object edFitRangeMin: TFloatSpinEdit AnchorSideLeft.Control = cbFitRangeUseMin @@ -326,7 +326,7 @@ object frmMain: TfrmMain MinValue = -1E308 OnChange = edFitRangeMinChange ParentFont = False - TabOrder = 2 + TabOrder = 1 Value = 5 Visible = False end @@ -377,7 +377,6 @@ object frmMain: TfrmMain Width = 53 BorderSpacing.Left = 16 BorderSpacing.Top = 8 - Enabled = False OnChange = edFitOrderChange ParentFont = False TabOrder = 1 @@ -392,7 +391,6 @@ object frmMain: TfrmMain Top = 39 Width = 114 Caption = 'Degree of polynomial' - Enabled = False ParentColor = False ParentFont = False end @@ -406,7 +404,7 @@ object frmMain: TfrmMain Height = 23 Hint = 'Select a function type to be used for fitting to the generated data' Top = 4 - Width = 277 + Width = 317 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 12 BorderSpacing.Top = 4 @@ -422,7 +420,7 @@ object frmMain: TfrmMain OnSelect = cbFitEquationSelect ParentFont = False Style = csDropDownList - TabOrder = 2 + TabOrder = 0 end object lblFitEquation: TLabel AnchorSideLeft.Control = gbFitting @@ -437,7 +435,7 @@ object frmMain: TfrmMain ParentColor = False ParentFont = False end - object GroupBox1: TGroupBox + object gbFixedParams: TGroupBox AnchorSideLeft.Control = lblFitEquation AnchorSideTop.Control = edFitOrder AnchorSideTop.Side = asrBottom @@ -446,16 +444,16 @@ object frmMain: TfrmMain Left = 14 Height = 61 Top = 74 - Width = 352 + Width = 392 Anchors = [akTop, akLeft, akRight] AutoSize = True BorderSpacing.Top = 16 Caption = 'Fixed parameters (check to keep constant)' ClientHeight = 41 - ClientWidth = 348 - TabOrder = 3 + ClientWidth = 388 + TabOrder = 2 object cbFitParam0Fixed: TCheckBox - AnchorSideLeft.Control = GroupBox1 + AnchorSideLeft.Control = gbFixedParams AnchorSideTop.Control = edFitParam0 AnchorSideTop.Side = asrCenter Left = 16 @@ -464,14 +462,14 @@ object frmMain: TfrmMain Width = 44 BorderSpacing.Left = 16 Caption = 'b0 =' - OnChange = FixedParamsChanged + OnChange = cbFitParam0FixedChange ParentFont = False TabOrder = 0 end object edFitParam0: TFloatSpinEdit AnchorSideLeft.Control = cbFitParam0Fixed AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = GroupBox1 + AnchorSideTop.Control = gbFixedParams Left = 64 Height = 23 Top = 4 @@ -479,6 +477,7 @@ object frmMain: TfrmMain BorderSpacing.Left = 4 BorderSpacing.Top = 4 BorderSpacing.Bottom = 14 + Enabled = False MaxValue = 1E308 MinValue = -1E308 OnChange = FixedParamsChanged @@ -488,26 +487,27 @@ object frmMain: TfrmMain object cbFitParam1Fixed: TCheckBox AnchorSideTop.Control = cbFitParam0Fixed AnchorSideRight.Control = edFitParam1 - Left = 212 + Left = 252 Height = 19 Top = 6 Width = 44 Anchors = [akTop, akRight] Caption = 'b1 =' - OnChange = FixedParamsChanged + OnChange = cbFitParam1FixedChange ParentFont = False TabOrder = 2 end object edFitParam1: TFloatSpinEdit AnchorSideTop.Control = edFitParam0 - AnchorSideRight.Control = GroupBox1 + AnchorSideRight.Control = gbFixedParams AnchorSideRight.Side = asrBottom - Left = 256 + Left = 296 Height = 23 Top = 4 Width = 80 Anchors = [akTop, akRight] BorderSpacing.Right = 12 + Enabled = False MaxValue = 1E308 MinValue = -1E308 OnChange = FixedParamsChanged @@ -520,7 +520,7 @@ object frmMain: TfrmMain AnchorSideTop.Side = asrBottom AnchorSideRight.Control = cbFitEquation AnchorSideRight.Side = asrBottom - Left = 312 + Left = 352 Height = 23 Top = 272 Width = 54 @@ -540,7 +540,7 @@ object frmMain: TfrmMain AnchorSideTop.Control = edConfLevel AnchorSideTop.Side = asrCenter AnchorSideRight.Control = edConfLevel - Left = 220 + Left = 260 Height = 15 Top = 276 Width = 88 @@ -576,21 +576,21 @@ object frmMain: TfrmMain end end object pnlChart: TPanel - Left = 429 + Left = 469 Height = 527 Top = 8 - Width = 589 + Width = 549 Align = alClient BorderSpacing.Around = 8 BevelOuter = bvNone ClientHeight = 527 - ClientWidth = 589 + ClientWidth = 549 TabOrder = 1 object Chart: TChart Left = 0 Height = 485 Top = 0 - Width = 589 + Width = 549 AxisList = < item Grid.Visible = False @@ -698,12 +698,12 @@ object frmMain: TfrmMain Left = 0 Height = 42 Top = 485 - Width = 589 + Width = 549 Align = alBottom AutoSize = True BevelOuter = bvNone ClientHeight = 42 - ClientWidth = 589 + ClientWidth = 549 TabOrder = 1 object cbLogX: TCheckBox AnchorSideLeft.Control = pnlLog @@ -799,7 +799,7 @@ object frmMain: TfrmMain end end object Splitter1: TSplitter - Left = 416 + Left = 456 Height = 543 Top = 0 Width = 5 diff --git a/components/tachart/demo/fit/Main.pas b/components/tachart/demo/fit/Main.pas index de5ba2a3dc..1ccd7176fe 100644 --- a/components/tachart/demo/fit/Main.pas +++ b/components/tachart/demo/fit/Main.pas @@ -41,7 +41,7 @@ type ChartAxisTransformations: TChartAxisTransformations; edFitParam0: TFloatSpinEdit; edFitParam1: TFloatSpinEdit; - GroupBox1: TGroupBox; + gbFixedParams: TGroupBox; Label1: TLabel; lblNoiseY1: TLabel; LogarithmAxisTransform: TLogarithmAxisTransform; @@ -75,6 +75,8 @@ type procedure cbCombinedExtentChange(Sender: TObject); procedure cbDrawFitRangeOnlyClick(Sender: TObject); procedure cbFitEquationSelect(Sender: TObject); + procedure cbFitParam0FixedChange(Sender: TObject); + procedure cbFitParam1FixedChange(Sender: TObject); procedure cbHTMLChange(Sender: TObject); procedure cbShowConfidenceIntervalsChange(Sender: TObject); procedure cbShowErrorbarsChange(Sender: TObject); @@ -263,6 +265,18 @@ begin end; end; +procedure TfrmMain.cbFitParam0FixedChange(Sender: TObject); +begin + edFitParam0.Enabled := cbFitParam0Fixed.Checked; + FixedParamsChanged(Sender); +end; + +procedure TfrmMain.cbFitParam1FixedChange(Sender: TObject); +begin + edFitParam1.Enabled := cbFitParam1Fixed.Checked; + FixedParamsChanged(Sender); +end; + procedure TfrmMain.cbHTMLChange(Sender: TObject); begin if cbHTML.Checked then Chart.Legend.TextFormat := tfHTML else Chart.Legend.TextFormat := tfNormal; diff --git a/components/tachart/tafuncseries.pas b/components/tachart/tafuncseries.pas index 09dd5ede88..11270aeccd 100644 --- a/components/tachart/tafuncseries.pas +++ b/components/tachart/tafuncseries.pas @@ -2148,7 +2148,7 @@ begin Result := NaN; if (FState = fpsValid) and Assigned(FFitStatistics) then begin sig2 := FFitStatistics.VarCovar[AIndex, AIndex]; - if not IsNaN(sig2) then + if not IsNaN(sig2) and (sig2 >= 0) then Result := sqrt(sig2); end; end;