Re: Save settings of series ?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
nileiqi
Newbie
Newbie
Posts: 16
Joined: Wed May 03, 2006 12:00 am

Re: Save settings of series ?

Post by nileiqi » Fri Mar 09, 2007 3:49 am

Hi,

I have a chart series1, it is defined as standard line in code as below,

Series1: TLineSeries;

It can be change to Bar (TBarSeries) during run-time. However, it is defined as line in code, so every time when program starts, Series1 always be a line, our customer wants to keep last settings, that is, if Series1 has been changed to bar,next time when the programs start, it will be a bar not line, how do i achieve this ? Thanks.


Daniel

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Mar 09, 2007 8:47 am

Hi Daniel,

To achieve that you should export your chart to a .tee file, native TeeChart template file. For more information on how to export TeeChart please read Tutorial 12 - Exporting and Importing Charts. You'll find the tutorials at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

nileiqi
Newbie
Newbie
Posts: 16
Joined: Wed May 03, 2006 12:00 am

Post by nileiqi » Mon Mar 26, 2007 6:15 am

Hi,

I have read tutorial #12 and also other related posts in this forum.

I include TeeEditPRO unit in my code. Below are bits of code, my question follows the code.

type
TMainForm = class(TForm)
....
series1 : TSeriesLine;

procedure MainForm.FormShow();
var
tmpChart:TCustomChart;
begin
DataChart.Free;
tmpChart:=TChart.Create(Self);
LoadChartfromFile(tmpChart,'cfg.tee');
DataChart := tmpChart as TChart;
DataChart.Parent:=Self;
end

procedure MainForm.FormClose();
begin
SaveChartToFile(DataChart, 'cfg.tee',False);
end;

Series1 is hard coded as TSeriesLine. User is allowed to change to other type at run-tome, such as bar. I just want save the settings, not graphics. The ploting can be done by pressing a button.

In function FormShow(), A .tee file is called, so the settings is loaded. In FormClose(), settings is saved to the .tee file.

It seems to me SaveChartFile() and LoadChartfromFile() work fine, but when I press a button to operate on series1, such as

Series1.clear() or Series1.AddXY()

I get a "Access violation" error message. It seems to me that I need to do something on series1, can you please point me how ? Thanks in advance.

Daniel

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Mar 26, 2007 8:05 am

Hi Daniel,

Most likely that when importing a chart the series variable name is not persisted.

You could either assign first chart series to your variable, something like:

Code: Select all

Series1:=Chart1[0];
Or directly use TeeChart's series collection, for example:

Code: Select all

Chart1[0].Clear;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

nileiqi
Newbie
Newbie
Posts: 13
Joined: Fri Jan 12, 2007 12:00 am

Post by nileiqi » Tue Mar 27, 2007 1:38 pm

Hi Narcis,

I still not sure
(1) What does

Code: Select all

 Series1:=Chart1[0] mean here ? 
(2) In existing code, Serise1 is defined as TLineSeries type, should it be TChartSeries ? because it may change type to TBarSeries.

Thanks in advance.

Daniel

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 27, 2007 2:03 pm

Hi nileiqi,

Suggestion 1 assigns the first series in a chart to the Series1 variable. However, the easier one may be suggestion 2 as this will always work if TChartSeries objects so no type cast will be necessary.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

nileiqi
Newbie
Newbie
Posts: 16
Joined: Wed May 03, 2006 12:00 am

Post by nileiqi » Wed Mar 28, 2007 3:21 am

Hi Narcis

Thanks, I got it. excellent support!

javascript:emoticon(':D')
Very Happy

Kind regards

Daniel

Post Reply