Page 1 of 1

Re: Save settings of series ?

Posted: Fri Mar 09, 2007 3:49 am
by 9043243
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

Posted: Fri Mar 09, 2007 8:47 am
by narcis
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.

Posted: Mon Mar 26, 2007 6:15 am
by 9043243
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

Posted: Mon Mar 26, 2007 8:05 am
by narcis
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;

Posted: Tue Mar 27, 2007 1:38 pm
by 9243843
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

Posted: Tue Mar 27, 2007 2:03 pm
by narcis
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.

Posted: Wed Mar 28, 2007 3:21 am
by 9043243
Hi Narcis

Thanks, I got it. excellent support!

javascript:emoticon(':D')
Very Happy

Kind regards

Daniel