Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 992 - Sub chart datasources are not memorized
Summary: Sub chart datasources are not memorized
Status: CONFIRMED
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Other Components (show other bugs)
Version: unspecified
Hardware: PC Windows
: High major
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-05 10:27 EST by h.hasenack
Modified: 2015-02-06 04:09 EST (History)
1 user (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version: RAD XE5, RAD XE6, RAD XE7


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description h.hasenack 2014-11-05 10:27:31 EST
Hello

I allow my customers to create custom charts using the chart editor. The charts manipulated using the regular teeditir. 

When using the subchart tool however, the chart data sources are NOT stored (or their links to it). Designtime mode allows linking up perfectly, beut later when the chart is restored (with the subcharts) the subcharts series are not linked to theit original data source anymore. 

Strangely enough the same does not occur when using teefunctions, they appear to work as expected. 

I can use teefunctions as a workaround for my custom data linking, but I would rather like to use the data source way.

Reproduce:
1 create form and add chart
2 edit chart, add subchart tool
3 add subchart
4 add subchart series
5 link subchart series to a data source (eg xml source)
6 store your form
7 close & reopen form
8 check subchart series datasource. It’s empty. 

Also, the TSubChart stores the subchart data in unreadable format stream in the dfm file. It would be nice to optionally store it in dfm/text format as well (as a large string) so it’s contents can be examined more easily.

Met vriendelijke groet,

Hans Hasenack
S&G Asset Management
Bijsterhuizen 1160b
Nijmegen
024 6450006
 (reported by email 22-10-2014 but no response yet)
Comment 1 h.hasenack 2015-02-06 04:09:57 EST
I have created a 2 step fix.

1) in my code where the frame with the chart/subchart is dynalically saved/loaded, I had to surround the ReadComponent call with GlobalLoading routines:

BeginGlobalLoading;
try
  MyFrame:=aStream.ReadComponent;
  NotofyGlobalLoading; // calls Loaded for all loaded components, including subcharts
finally
  EndGlobalLoading;
end;


2a) Secondly, I had to patch the TChartSeries.Loaded routine to not only look in the direct owner, but a bit further in the hierarchy as well:

Procedure TChartSeries.Loaded;
{$ifdef HH_PATCH_TC_GETDATASOURCE}
  function lclResolveDatasourceByName(const aName:string):TCOmponent;
  VAR O:TComponent;
  begin
    Result:=nil;
    O:=Owner;
    // try to find as component owned by one of the parent components
    while Assigned(O) and not Assigned(Result) do
    begin
      Result:=O.FindComponent(aName);
      O:=O.GetParentComponent;
    end;

    O:=Owner;
    // try to find as component owned by one of the owner components
    while Assigned(O) and not Assigned(Result) do
    begin
      Result:=O.FindComponent(aName);
      O:=O.Owner;
    end;
  end;
{$endif}
var t : Integer;
begin
  inherited;

  { when the DataSource has multiple Series, load them... }
  if Assigned(FTempDataSources) then
  begin
    if FTempDataSources.Count>0 then
    begin
      DataSources.Clear;
      for t:=0 to FTempDataSources.Count-1 do
{$ifdef HH_PATCH_TC_GETDATASOURCE}
          InternalAddDataSource( lclResolveDatasourceByName(FTempDataSources[t]) );
{$else}
          InternalAddDataSource( Owner.FindComponent(FTempDataSources[t]) );
{$endif}
    end;

    FTempDataSources.Free;
  end;

  { finally, gather points from datasource after loading }
  CheckDatasource;
end;



2b) And I patched the TChartSeries.IsDataSOurceStored to always return False so it will always use the Dataseources property to store datasource links, while still maintaining backwards compatability for existing forms.