Issue with reloading a chart saved to a custom DFM file
Issue with reloading a chart saved to a custom DFM file
1. Run the program - a chart will be seen on the form.
2. click 'Change Color' and see the chart background change.
3. Click 'save' and a file 'test.txt' is written to your desktop - open it and you will see the saved properties.
4. Click 'load' and see the chart reloaded showing only axes. Where is the series? It is there in code but not visible.
Any help appreciated. Thanks, Brian.
As a test for a wrapper I have created my own panel component at runtime which contains a TChart. Again, at runtime I show this panel on a form
Re: Issue with reloading a chart saved to a custom DFM file
Hi Brian,
You aren't exporting the series data. Set the ForceSaveData property to true to do so:
You aren't exporting the series data. Set the ForceSaveData property to true to do so:
Code: Select all
type
//...
TSeriesAccess=class(TChartSeries);
//...
constructor TMyChart.Create(AOwner: TComponent);
begin
//...
TSeriesAccess(FChart.Series[0]).ForceSaveData:=True;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Issue with reloading a chart saved to a custom DFM file
Hi Yerey,
I dont want or need to export the series data - if you look at the code you will see that I am using 'FillRandom' to generate the series data - in my real app I make the data myself.
The problem is that the series gets created and IT HAS THE DATA (Chart1.Series[0].Count is 100) but it does not get displayed.
I dont want or need to export the series data - if you look at the code you will see that I am using 'FillRandom' to generate the series data - in my real app I make the data myself.
The problem is that the series gets created and IT HAS THE DATA (Chart1.Series[0].Count is 100) but it does not get displayed.
Re: Issue with reloading a chart saved to a custom DFM file
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:
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:
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:
Maybe something similar has to be done in your custom importation.
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;
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;
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;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Issue with reloading a chart saved to a custom DFM file
Hi Yeray, Thanks for your suggestions. I will investigate.