View Issue Details

IDProjectCategoryView StatusLast Update
0035179LazarusTAChartpublic2019-03-03 18:52
ReporterMarcin Wiazowski Assigned Towp  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.1 (SVN) 
Target Version2.2 
Summary0035179: TAChart: some issue with TFitSeries.AutoFit / SetFitBasisFunc
DescriptionThe attached Reproduce application has a chart with TFitSeries, having FitEquation = feCustom.

In FormCrate(), calls to SetFitBasisFunc() are made - as needed in the feCustom mode.

The problem is: curve is not displayed.



Explanation: the loading order is:

1) TFitSeries.SourceChanged() is called, but we are in csLoading state, so nothing important happens.

2) TFitSeries.Loaded() is called - however, it does nothing for FitEquation = feCustom.

3) TListChartSource.Loaded() is called - it changes source contents.

4) Source contents have been changed, so TFitSeries.SourceChanged() is called again - it executes ExecFit() internally. But there are no basis functions (set by SetFitBasisFunc() calls) at this moment, so ExecFit() stucks with FState = fpsInvalid. This prevents drawing the curve.

5) FormCreate() is called, where TFitSeries.SetFitBasisFunc() calls are made - but it's already too late.



Solution: SetFitBasisFunc() in fact changes the interpolation, so it should invalidate the current, internal interpolation state.

The attached patch solves the problem.
TagsNo tags attached.
Fixed in Revision60567
LazTarget2.2
WidgetsetWin32/Win64
Attached Files

Activities

Marcin Wiazowski

2019-03-03 00:25

reporter  

Reproduce.zip (2,450 bytes)

Marcin Wiazowski

2019-03-03 00:26

reporter  

patch.diff (815 bytes)   
Index: components/tachart/tafuncseries.pas
===================================================================
--- components/tachart/tafuncseries.pas	(revision 60564)
+++ components/tachart/tafuncseries.pas	(working copy)
@@ -2142,8 +2142,14 @@
   if not InRange(AIndex, 0, ParamCount - 1) then
     raise EChartError.CreateFmt(SIndexOutOfRange, [NameOrClassName(self), 'SetFitBasisFunc']);
 
+  FFitParams[AIndex].CustomFuncName := AFitFuncName;  // e.g. 'sin(x)';
+
+  if FFitParams[AIndex].CustomFunc = AFitFunc then exit;
   FFitParams[AIndex].CustomFunc := AFitFunc;
-  FFitParams[AIndex].CustomFuncName := AFitFuncName;  // e.g. 'sin(x)';
+  if FFitEquation = feCustom then begin
+    InvalidateFitResults;
+    UpdateParentChart;
+  end;
 end;
 
 procedure TFitSeries.SetFitRange(AValue: TChartRange);
patch.diff (815 bytes)   

wp

2019-03-03 11:11

developer   ~0114595

Applied, r60567. Thanks.

Marcin Wiazowski

2019-03-03 18:52

reporter   ~0114602

Fix confirmed - thanks.

Issue History

Date Modified Username Field Change
2019-03-03 00:25 Marcin Wiazowski New Issue
2019-03-03 00:25 Marcin Wiazowski File Added: Reproduce.zip
2019-03-03 00:26 Marcin Wiazowski File Added: patch.diff
2019-03-03 10:26 wp Assigned To => wp
2019-03-03 10:26 wp Status new => assigned
2019-03-03 11:11 wp Note Added: 0114595
2019-03-03 11:12 wp Fixed in Revision => 60567
2019-03-03 11:12 wp LazTarget => 2.2
2019-03-03 11:12 wp Status assigned => resolved
2019-03-03 11:12 wp Resolution open => fixed
2019-03-03 11:12 wp Target Version => 2.2
2019-03-03 18:52 Marcin Wiazowski Note Added: 0114602
2019-03-03 18:52 Marcin Wiazowski Status resolved => closed