TFitSeries issues with TUserDefinedChartSource lazarus / 55-TAChart ---------------------------------------------------------------------- wp · 2012-08-05 21:49 While preparing a new tutorial I came across a situation that a TFitSeries getting its data from a UserDefinedChartSource tries to redraw before the fit is performed. As a consequence, the DrawFuncHelper crashes becauses of the NaNs produced along the way. A workaround would be to exit the Draw method if the fit had not yet beein performed or was not successful. The new TFitSeries.Draw method, therefore, should be like this: Code: [Select]procedure TFitSeries.Draw(ADrawer: IChartDrawer); var   de : TIntervalList; begin   if IsEmpty or (not FValidFitParams) then exit;  // wp: added FValidFitParams   ADrawer.Pen := Pen;   de := PrepareIntervals;   try     with TDrawFuncHelper.Create(Self, de, @Calculate, Step) do       try         DrawFunction(ADrawer);       finally         Free;       end;   finally     de.Free;   end; end; ---------------------------------------------------------------------- Ask · 2012-08-06 13:02 Applied in r38179. A couple of notes: NaNs should not crash drawing of function series, I already know of the problem, but did not fix it yet -- this will be rather complex. Anyway, even without crash, this change would be an optimization, so it is good.I suspect that you forgot to call Reset to notify the chart about changes in the source. I have added a note about it to the documentation. ---------------------------------------------------------------------- wp · 2012-08-06 21:13 Thank you. QuoteNaNs should not crash drawing of function series The fit series had crashed in TDrawFuncHelper.CalcAt after FCalc(AXa) (calling TFitFunction.Calculate) returned a NaN because the fit had not yet been done. QuoteI suspect that you forgot to call Reset Good guess, yes I did not call Reset. After calling Reset, the project runs fine, even without yesterday's patch.