Save ALL Chart properties values to a file

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
beetle
Newbie
Newbie
Posts: 4
Joined: Fri Nov 15, 2002 12:00 am

Save ALL Chart properties values to a file

Post by beetle » Tue Jan 20, 2004 3:54 pm

Hi there!
I would like to know if it is possible to save ALL the Chart properties values to a file. I use the 'SaveChartToFile' procedure but there is a problem with it. This procedure does not save to file ALL the properties, only saves the non-default properties values. Example:

If you have a Chart with the property:
Legend.Visible = True
saving the chart to a file will not include the line 'Legend.Visible = True'
to the file because any chart has this property = true by default.
Then , if I load another Chart with the property Legend.Visible = false
from this file with 'LoadChartFromFile', the property Legend.Visible will
not change, it will be 'false'.

This problem would be solved saving all the chart properties values in the file.

Any solutions?

Thanks in advance.

Pablo.

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Jan 21, 2004 12:04 am

Hi Pablo,

SaveChartToFile does not saves all properties of Chart, only changes
to the default state, so you must initialize yourself the whole Chart
or at least some parameters that are important to you.

The best way to initialize a Chart is to re-create it:

Code: Select all

procedure InitChart(var Sender: TChart);
var tmp : TChart;
begin
  tmp:=TChart.Create(Sender.Owner);
  tmp.BoundsRect:=Sender.BoundsRect;
  tmp.Parent:=Sender.Parent;
  Sender.Free;
  Sender:=tmp;
end;

//init default values
InitChart(Chart1);

//now load test.tee
LoadChartFromFile( TCustomChart(Chart1), 'test.tee');

beetle
Newbie
Newbie
Posts: 4
Joined: Fri Nov 15, 2002 12:00 am

Post by beetle » Wed Jan 21, 2004 10:26 am

Hi Pep! This is the solution I took when I discover that problem, but there is another problem if you change the chart pointer. For example, if you have a PopupMenu assigned to the chart property 'PopupMenu', it will not be saved in the file with 'SaveChartToFile', you would have to assign it in your code, but I think it could be more properties like this.

It would be great to set the default values for an existing chart. :lol:

Anyway thank you so much.

Any more ideas?

Pablo.

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Feb 10, 2004 1:23 pm

Hi.

TChart uses Delphi streaming system to save it's properties and inherits all it's limitations. This means that in some cases you'll have to manually re-initialize some properties and events after chart is loaded. The easiest workaround I can think is to use the approach you're already using.
Marjan Slatinek,
http://www.steema.com

Post Reply