My codes from testFit.zip
==================================
procedure TForm1.ComboBox2Select(Sender: TObject);
begin
case ComboBox2.ItemIndex of
0: begin
SpinEdit1.Enabled:=False;
Chart1FitSeries1.Clear;
end;
1: begin
SpinEdit1.Enabled:=True;
Chart1FitSeries1.FitEquation:=fePolynomial;
SpinEdit1Change(Sender);
PlotFitCurve();
end;
2: begin
SpinEdit1.Enabled:=False;
Chart1FitSeries1.FitEquation:=fePower;
PlotFitCurve();
end;
end;
end;
procedure TForm1.PlotFitCurve();
var
MinVals, MaxVals, i: Integer;
X,Y: Real;
begin
if ComboBox1.ItemIndex>0 then
begin
with StringGrid1 do
begin
if RowCount>0 then
begin
Chart1FitSeries1.Clear;
if SpinEdit2.Enabled then
MinVals:=SpinEdit2.Value else MinVals:=SpinEdit2.MinValue;
if SpinEdit3.Enabled then
MaxVals:=SpinEdit3.Value else MaxVals:=SpinEdit3.MaxValue;
for i:=1 to RowCount-1 do
begin
if (Cells[2,i]<>EmptyStr) and
(Cells[3,i]<>EmptyStr) and
(Cells[4,i]<>EmptyStr) and
(Cells[5,i]<>EmptyStr) and
(Cells[6,i]<>EmptyStr) then
begin
if (StrToInt(Cells[2,i])>=MinVals) and
(StrToInt(Cells[2,i])<=MaxVals) then
begin
case ComboBox1.ItemIndex of
1: begin
X:= StrToFloat(Cells[3,i]); // Lpp
Y:= StrToFloat(Cells[4,i]); // B
end;
2: begin
X:= StrToFloat(Cells[5,i]); // D
Y:= StrToFloat(Cells[6,i]); // T
end;
end;
Chart1FitSeries1.AddXY(X,Y,Cells[1,i]);
end;
end;
end;
Chart1.Refresh;
end;
end;
end;
end;
==========================
thanks
tbk