Hi Brian,
We've been looking at this, modifying your loading routine in different ways, etc.
I'm not sure about what is wrong here but maybe our test give you some kind of clue to find it.
First, I've added a new button to open the editor:
Code: Select all
uses VCLTee.TeeEdit;
procedure TForm8.BEditorClick(Sender: TObject);
begin
with TChartEditor.Create(Self) do
begin
Chart:=FMyChart.Chart;
Execute;
end;
end;
If you click Save&Load and then you open the editor, you can see how the global variable FMyChart seems to be still referencing the old chart; the chart with a series and data.
So this smells like FMyChart variable has been, at least partially broken.
Furthermore, if you reassign the FMyChart Parent and you set its Chart.Align to alNone after loading the stream, you'll observe how the original FMyChart seems to be restored:
Code: Select all
LoadComponentFromFile( TComponent(FMyChart) );
FMyChart.Chart.Parent:=Self;
FMyChart.Chart.Align:=alNone;
Since you are a SourceCode customer I'd suggest you to take a look at how SaveChartToFile and LoadChartFromFile (TeeStore.pas) methods are implemented.
I'd also suggest you to see how in the "Tutorial 12 - Exporting and Importing Charts", when we import a chart from a file, we Free the original chart, we load the stream to a tmpChart and we assign it to the original freed chart:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var tmpChart : TCustomChart;
begin
Chart1.Free; // Assuming Chart1 is already on the Form
tmpChart:=TChart.Create(Self);
With OpenDialog1 do
begin
Filter:= 'Teefiles|*.tee';
if Execute then
LoadChartfromFile(tmpChart,OpenDialog1.FileName);
end;
Chart1 := tmpChart as TChart;
With Chart1 do
begin
Parent:=Self;
end;
end;
Maybe something similar has to be done in your custom importation.