GoodnessOfFit deprecated lazarus / 55-TAChart ---------------------------------------------------------------------- tambok · 2019-03-09 09:59 Hi, I change the GoodnessOfFit in Lazarus fit demo 1.80 to 2.0, but it make error or R-squared has constant Null result. How can i change this line: Add(Format('R-Squared = %g', [FitSeries.GoodnessOfFit])); Thanks Tbk ---------------------------------------------------------------------- wp · 2019-03-09 10:17 GoodnessOfFit became obsolete when the more complete FitStatistics has been introduced in Laz 2.0 and it was marked as being deprecated. Recently I removed the GoodnessOfFit-related code from trunk which therefore will not be included any more in Laz 2.2. In Laz 2.0+ use the more comprehensive values in FitSeries.FitStatistics. The old GoodnessOfFit corresponds to FitSeries.FitStatistics.R2. A description of the FitStatistics is given in the wiki documentation. ---------------------------------------------------------------------- tambok · 2019-03-09 11:49 Solved. Thank you WP. Tbk ---------------------------------------------------------------------- Thaddy · 2019-03-09 13:01 @wp Shouldn't that be fpc math instead of Lazarus? ---------------------------------------------------------------------- wp · 2019-03-09 13:40 Yes, in principle. But it is much easier for me to maintain it when it is in Lazarus. And fpc won't have it before version 3.4 which means half a decade in the future  ;-), therefore, Lazarus will need a temporary solution anyway. But when I have some spare time I can prepare a patch for fpc's numlib. ---------------------------------------------------------------------- DesJardins · 2019-05-08 21:45 Ref:  TAChart Tutorial: ListChartSource, Logarithmic Axis, Fitting  I want to get this to work so I can modify it to my program which requires a log-log plot y axis log 0.2 to log 20 and x axis log 0.2 to log 4.  I need to draw least-squares line.  1)  It won't draw the line.  2) the example shows  fit a=4,35889289...E-275 and b:= 0.3244733...  and I get a = 0 and b= 0.3244733... Why don't I get the same value for a? my input is exactly as shown in the example for ListChartSource1. What procedure is hidden that is not getting used. What could I be missing?  What procedure is hidden that is not getting used.  Why won't it draw the line?  3) My input shows labels for each point in yellow with chip type just as in the example, but when I compile and run the program those yellow labels do not show.  It shows the points like the example and I can connect with line point to point, but it does not show the label.  Why?   I need to I Iuse labels because I eventually want to segregate points at a certain temperature range and points at a certain velocity range and draw lines between those that are related.  I have been triple checking the Object Inspector for at least 6 weeks and just cannot find the problem. Here is Unit 1 unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, TAGraph, TASeries, TASources, Forms, Controls,   Graphics, Dialogs, TAChartUtils, TATransformations,  TACustomSource,   TAFuncSeries,  TACustomSeries, typ, Types, TAChartAxisUtils; type   { TForm1 }   TForm1 = class(TForm)     Chart1: TChart;     Chart1FitSeries1: TFitSeries;     Chart1LineSeries1: TLineSeries;     ChartAxisTransformations1: TChartAxisTransformations;     ChartAxisTransformations1LogarithmAxisTransform1: TLogarithmAxisTransform;     ListChartSource1: TListChartSource;     ListChartSource2: TListChartSource;     procedure Chart1AxisList0MarkToText(var AText: String; AMark: Double);     procedure Chart1FitSeries1FitComplete(Sender: TObject);     procedure FormCreate(Sender: TObject);     procedure Chart1AfterDrawBackWall(ASender: TChart; ACanvas: TCanvas;       const ARect: TRect);     procedure Chart1FitSeries1CalcGoodnessOfFit(Sender: TObject; var x,       y: ArbFloat; n: Integer; out AResult: Double);     procedure Chart1LineSeries1DrawPointer(ASender: TChartSeries;       ACanvas: TCanvas; AIndex: Integer; ACenter: TPoint);     procedure Chart1LineSeries1GetMark(out AFormattedMark: String;       AIndex: Integer);    private       { private declarations }    public       { public declarations }    end; var   Form1: TForm1; implementation {$R *.lfm} uses   Math; { TForm1 } procedure TForm1.FormCreate(Sender: TObject); const   MIN = 0;   MAX = 12; var   i: Integer;   value: double; begin   for i:=MIN to MAX do begin     value := Power(10, i);     ListChartSource2.Add(value, value);   end;   Chart1FitSeries1.execFit; end;  procedure TForm1.Chart1FitSeries1FitComplete(Sender: TObject); begin   with Chart1FitSeries1 do     ShowMessage(Format(       'Fit result: a = %g, b = %g', [       Param[0], Param[1]     ]));   Chart1.Title.Text.Add(Format(     'The number of transistors doubles every %.0f years',     [ln(2) / Chart1FitSeries1.Param[1]]   ));   end; procedure TForm1.Chart1AxisList0MarkToText(var AText: String; AMark: Double); begin end; procedure TForm1.Chart1LineSeries1DrawPointer(ASender: TChartSeries;   ACanvas: TCanvas; AIndex: Integer; ACenter: TPoint); begin end; procedure TForm1.Chart1LineSeries1GetMark(out AFormattedMark: String;   AIndex: Integer); begin end; procedure TForm1.Chart1FitSeries1CalcGoodnessOfFit(Sender: TObject; var x,   y: ArbFloat; n: Integer; out AResult: Double); begin end; procedure TForm1.Chart1AfterDrawBackWall(ASender: TChart; ACanvas: TCanvas;   const ARect: TRect); begin end; end.     object Chart1: TChart   Left = 0   Height = 548   Top = 0   Width = 632   AxisList = <      item       Grid.Color = clBlue       Grid.Style = psSolid       Intervals.Count = 9       Intervals.MaxLength = 100       Intervals.MinLength = 100       Intervals.NiceSteps = '1|5|10'       Intervals.Options = [aipUseCount, aipUseMinLength]       Intervals.Tolerance = 100       TickColor = clDefault       AxisPen.Visible = True       LabelSize = 1       Marks.Alignment = taCenter       Marks.Margins.Left = 25       Marks.Margins.Top = 24       Marks.Margins.Right = 24       Marks.Margins.Bottom = 24       Marks.LabelFont.Color = clBlack       Marks.LabelFont.Height = -13       Marks.LabelFont.Style = [fsBold]       Marks.Format = '%0.0n'       Marks.Frame.Color = clWhite       Marks.Source = ListChartSource1       Marks.Style = smsCustom       Minors = <              item           Grid.Visible = False           Intervals.Count = 9           Intervals.MaxLength = 100           Intervals.MinLength = 50           Intervals.NiceSteps = '0.5|1.0'           Intervals.Options = [aipUseCount]           Intervals.Tolerance = 1000           Visible = False           Marks.Margins.Left = 50           Marks.Margins.Top = 24           Marks.Margins.Right = 24           Marks.Margins.Bottom = 24           Marks.LabelFont.Orientation = 900           Marks.LabelFont.Style = [fsBold]           Marks.Visible = False           Marks.Format = '%0:.9g'           Marks.Style = smsValue         end>       Title.Margins.Left = 5       Title.Margins.Right = 2       Title.Distance = 100       Title.LabelFont.Color = clBlack       Title.LabelFont.Height = -16       Title.LabelFont.Orientation = 900       Title.LabelFont.Style = [fsBold]       Title.Visible = True       Title.Caption = 'Number of Transistors'       Title.Frame.Color = clWhite       Transformations = ChartAxisTransformations1       OnMarkToText = Chart1AxisList0MarkToText     end      item       Grid.Color = clBlue       Grid.Style = psSolid       Intervals.Count = 9       Intervals.MaxLength = 70       Intervals.MinLength = 100       Intervals.Options = [aipGraphCoords, aipUseCount, aipUseMaxLength, aipUseNiceSteps]       Alignment = calBottom       Marks.LabelFont.Style = [fsBold]       Marks.Format = '%0.0f'       Marks.Style = smsCustom       Minors = <              item           Intervals.MinLength = 5           Intervals.Options = [aipUseCount, aipUseMinLength]         end>       Title.LabelFont.Height = -16       Title.LabelFont.Style = [fsBold]       Title.Visible = True       Title.Caption = 'Year of market introdution'     end>   BackColor = clWhite   Foot.Alignment = taLeftJustify   Foot.Margins.Left = 24   Foot.Margins.Right = 24   Foot.Brush.Color = clBtnFace   Foot.Brush.Style = bsClear   Foot.Font.Color = clBlue   Foot.Margin = 0   Foot.Text.Strings = (     'Source'     'http://www.intel.com'   )   Foot.Visible = True   Legend.GridHorizontal.Style = psDot   Legend.GridHorizontal.Visible = True   Legend.GridVertical.Style = psDot   Legend.GridVertical.Visible = True   Legend.UseSidebar = False   Margins.Left = 24   Margins.Top = 10   Margins.Right = 24   Margins.Bottom = 24   MarginsExternal.Left = 10   MarginsExternal.Top = 24   MarginsExternal.Right = 24   MarginsExternal.Bottom = 5   Title.Brush.Color = clBtnFace   Title.Brush.Style = bsClear   Title.Font.Color = clBlack   Title.Font.Height = -19   Title.Font.Style = [fsBold]   Title.Text.Strings = (     'Progress in Micorelectronics'   )   Title.Visible = True   Align = alClient   ParentColor = True   ParentShowHint = False   ShowHint = True   OnClick = FormCreate   object Chart1LineSeries1: TLineSeries     Marks.LabelFont.Style = [fsBold]     Marks.Shape = clsEllipse     Marks.Format = '%2:s'     Marks.LinkDistance = 1     Marks.LinkPen.Color = clBlack     Marks.Style = smsLegend     OnGetMark = Chart1LineSeries1GetMark     AxisIndexX = 1     AxisIndexY = 0     OnDrawPointer = Chart1LineSeries1DrawPointer     Pointer.Brush.Color = clRed     Pointer.Style = psCircle     ShowPoints = True     Source = ListChartSource1   end   object Chart1FitSeries1: TFitSeries     Shadow.Visible = True     Marks.Alignment = taRightJustify     Marks.LabelFont.Style = [fsBold]     Marks.Shape = clsEllipse     Marks.Arrow.Visible = True     Marks.Format = '%2:s'     Marks.LabelBrush.Style = bsDiagCross     Marks.LinkDistance = 1     Marks.LinkPen.Color = clBlack     Marks.Style = smsLegend     AxisIndexX = 1     AxisIndexY = 0     DrawFitRangeOnly = False     FitEquation = feExp     FitRange.UseMin = True     ParamCount = 2     Source = ListChartSource1     OnCalcGoodnessOfFit = Chart1FitSeries1CalcGoodnessOfFit     OnFitComplete = Chart1FitSeries1FitComplete   end end What am I missing?  Could there be a problem with math unit etc?  Why won't it draw the line?  All I am trying to do at this time is basically duplicate the example. Richard ---------------------------------------------------------------------- wp · 2019-05-08 22:00 Please pack the file required to compile your program into a zip and upload it here (under "Attachments and other options"), but only pas, lfm, lpi, lpr and data files (if needed), please no binaries.