Page 1 of 1

Just save the properties of a chart ?

Posted: Thu Jan 20, 2005 12:55 pm
by 8439980
I am offering the user the chart editor for fully customising a chart that is created with selected subsets of his data. Now it is very annoying for a user to customize the background, (custom-)axes, ticks, colors..............and everything else and to loose it with the next program start.

Especially for creating a set of scientific charts it is interesting to keep these information.

My questions is: is there a possibility to save the properties of a chart (without the data!) in an easy way? I think about a template that can be loaded and reused. It would already be a great advantage if i could save the (custom-) axes with colors, fonts, angles, min, max, automatic min-max or not and so on...
Do you already have a solution for this problem? I tried to find something in the manual, but did not find anything, that seems to to fit.

Thanks

Jan

Posted: Thu Jan 20, 2005 1:08 pm
by narcis
Hi Jan,

You can use the SaveChartToFile procedure. This method will save the current chart as a TeeChart 'tee' template to the specified File Name.

The IncludeData boolean parameter determines if Series point values are stored or not together with the template definition.

Posted: Thu Jan 20, 2005 1:17 pm
by 5890703
I used the SaveChartToFile() function. This saves everything, including the data. Perhaps in your case it might be possible to search for all datasets and clear them before saving. If not, it is easy for the user to select and clear all unwanted series in the Chart tab | Series tab. All other properties should remain as previously configured.

Posted: Thu Jan 20, 2005 1:51 pm
by narcis
Hi Hans,

Have you tried setting the IncludeData parameter to false?

Posted: Thu Jan 20, 2005 2:11 pm
by 8439980
Wonderful!!

Thanks to both of you! I did not hear about the (Save/Load)Chart(To/From)File function before. It sounds great!

Just another question (i don't have a Delphi version available here at the moment): Is it possible to create a chart, fill different series with data and load these specifications thereafter?

Is the code that easy as I imaging at the moment? (I have ben thinking about an own routine for 3 days now!) Will have a closer look into the on-line help tonight...

Many thanks

Jan

Posted: Thu Jan 20, 2005 2:37 pm
by narcis
Hi Jan,
Just another question (i don't have a Delphi version available here at the moment): Is it possible to create a chart, fill different series with data and load these specifications thereafter?


Is the code that easy as I imaging at the moment? (I have ben thinking about an own routine for 3 days now!) Will have a closer look into the on-line help tonight...
Yes, this can be done. Have a look also at the Tutorials provided with the installation. One of them speaks specifically about importing and exporting.

Posted: Mon Jan 24, 2005 7:54 am
by 8439980
I still have problems with the templates. After several tries i managed it to get a template loaded. This was not possible for me with the TCustomChart type, as mentioned. I always got the Read Exceptions XYZ does not exist (as Rob in the other thread). I solved it by using a TChart. type and not a TCustomChart. Have an own look, maybe you can tell/show me what's wrong.

But the more important point is: Saving a template from a chart with 6 CustomAxis seems to work fine. It can be loaded with Tee office and the properties look correct. But if reloading a template on a chart, the series on the two custom axes are set to the left and bottom axis, overturning the min/max properties of these and looks awful.

The series are already generated when i load the template and the changes are done after loading. Normally this is no larger problem, but if these series are a couple of bar series, up to ten have to be readjusted again to the custom axes.... No good

Maybe jou can help me with this problem. We are having a presentation on Wednesday, do you think it can be solved? It would make several things much easier...

Thanks, Jan

procedure TfrmGraphic.btSaveTemplateClick(Sender: TObject);
Var tmpChart : TCustomChart;
begin
Chart1.OnZoom := NIL; //All events have to be disconnected!!!
Chart1.OnUndoZoom := NIL;

tmpChart := TChart.Create (Self); //Create a tmp chart,
tmpChart.Assign (Chart1); // copy the whole chart and ..
tmpChart.Parent := Self;
tmpChart.FreeAllSeries(); // ..delete the series -> we got a template

With SaveChartTemplateDialog do
Begin
Filter:='Teefiles|*.tee';
if Execute then SaveChartToFile (tmpChart, FileName, False, True); // save the template, name, no data, as text
end;

FreeAndNil (tmpChart); // finally free the temp chart

Chart1.OnZoom := Chart1Zoom; // and reconnct the events!
Chart1.OnUndoZoom := Chart1UndoZoom;
end;


procedure TfrmGraphic.btLoadTemplateClick(Sender: TObject);
Var tmpChart : TChart;
begin
Chart1.OnZoom := NIL; // the events have to be disconnected!!!
Chart1.OnUndoZoom := NIL;

tmpChart := TChart.Create (Self); // create a temp chart

With LoadChartTemplateDialog do
Begin
Filter := 'Teefiles|*.tee';
if Execute then LoadChartFromFile (TCustomChart(tmpChart), FileName); // and load the template
end;

// tmpChart.PArent := Chart1;
Chart1.Assign (tmpChart as TChart); // now we copy everything to our chart

With Chart1 do
Begin
Parent := Self;
end;

FreeAndNil (tmpChart); // free the temp chart

Chart1.OnZoom := Chart1Zoom; // and reconnect the events
Chart1.OnUndoZoom := Chart1UndoZoom;
end;
[/quote]

Posted: Thu Jan 27, 2005 10:33 am
by Pep
Hi Jan,

I cannot reproduce the problem here, which Teechart Pro version are you using ? Could you please post an example into the news://steema.net/steema.public.attachments newsgroup with which I can reproduce "as is" problem here, so I can debug it and see what is happening ?