Question about ver 8 import / export functions

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
rackerson
Newbie
Newbie
Posts: 22
Joined: Mon Mar 08, 2004 5:00 am
Location: Edison, New Jersey USA

Question about ver 8 import / export functions

Post by rackerson » Tue Sep 18, 2007 3:34 pm

Hello,

We are looking to provide a way to build a chart and export it - both data and all markup settings - to a file. We would then like the ability to reimport this exported information to a TChart object and have a "new" live chart.

We are experimenting with the trial for version 8. I see there are several export functions for Text, XML, HTML, etc. For import, I see there is the ability to import from a *.TEE file.

Please bear with me for this question but can you elaborate on exactly *how* we could accomplish this little task? I created a simple test application consisting of one form with two TChart components. This form has three buttons. The first populates the first TChart with 3 series of sample data, the second exports the contents of Chart1 using SaveChartToFile, and the third tries to populate the second Chart from the export file created by button2.

Here is the source code for my one and only unit...

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Series, TeEngine, ExtCtrls, TeeProcs, Chart;

type
  TForm1 = class(TForm)
    btnCreate: TButton;
    btnExport: TButton;
    Chart1: TChart;
    btnImport: TButton;
    Chart2: TChart;
    procedure btnCreateClick(Sender: TObject);
    procedure btnExportClick(Sender: TObject);
    procedure btnImportClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses TeeStore;

procedure TForm1.btnCreateClick(Sender: TObject);
begin
  Chart1.AddSeries(TPieSeries);
  Chart1.AddSeries(TBarSeries);
  Chart1.AddSeries(TLineSeries);
  Chart1.SeriesList.FillSampleValues(15);
end;

procedure TForm1.btnExportClick(Sender: TObject);
begin
  SaveChartToFile(Chart1, 'c:\Export.tee', True);
end;

procedure TForm1.btnImportClick(Sender: TObject);
begin
  LoadChartFromFile(TCustomChart(Chart2), 'c:\Export.tee');
end;

end.
To import my data, I tried both the LoadChartFromFile method AND the TImportChart class's LoadFromFile method. Both report the same errors, neither can locate the needed Series classes to create my second chart. So where my source chart had three series (one bar, one line, one pie), during Import, I get three error messages "Class TBarSeries not found", "Class TPieSeries not found", and "Class TLineSeries not found".

Can you please tell me what I am doing wrong?

xxxxxx
Advanced
Posts: 128
Joined: Tue Jun 19, 2007 12:00 am
Location: Russia
Contact:

Re: Question about ver 8 import / export functions

Post by xxxxxx » Tue Sep 18, 2007 9:23 pm

9336044 wrote: Can you please tell me what I am doing wrong?
The code you put here must produce compiler errors ;)
Anyhow, add lines
RegisterClass(TPieSeries);
RegisterClass(TBarSeries);
RegisterClass(TLineSeries);
before
LoadChartFromFile(TCustomChart(Chart2), 'c:\Export.tee');
or include EditChar into uses clause.
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009

rackerson
Newbie
Newbie
Posts: 22
Joined: Mon Mar 08, 2004 5:00 am
Location: Edison, New Jersey USA

Post by rackerson » Tue Sep 18, 2007 10:40 pm

Thanks for the reply.

Nope, the code I posted produced NO compiler errors and I was even able to run the application. The only error came when I tried to run LoadChartFromFile.

Anyway, adding EditChar to the uses clause fixed the problem, although I did have to add a little more code because evidently the Save and Load methods save EVERYTHING, including placement on the screen. Until I backed up the original position of my destination chart, calling LoadChartFromFile not only made a mirror image of Chart1 in Chart2, it also moved Chart2 on top of Chart1, completely covering it.

What I don't understand is why I should have to add anything to my code. The Chart Series types I was using are declared in the Series unit, if I am not mistaken. The Series unit is already included in this project and I was able to reference the TPieSeries, TBarSeries, and TLineSeries types in the btnCreateClick method. Why should these be "lost" later on in the same module?

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

Post by Narcís » Wed Sep 19, 2007 8:44 am

Hi rackerson,

Before loading chart you have to register all series/tools classes you originally exported. This can be done by using RegisterTeeSeries(...) and RegisterTeeTool(...) routines. Or (much better and simpler solution) by including the TeeEditPRO unit to the import form Uses section. Including TeeEditPRO automatically registers all series/tool types.
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

MH3IM
Newbie
Newbie
Posts: 4
Joined: Mon May 03, 2010 12:00 am
Contact:

Re: Question about ver 8 import / export functions

Post by MH3IM » Wed May 05, 2010 6:39 am

Hello,

I am facing the same problem when try loading a tee chart template from a file. An error occured that a specific series class cannot be found. Adding the TeeEditPro Unit to the uses clause works but it also nearly doubles the size of the resulting application. Is there another way to register all series classes without that oversize?

Markus

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

Re: Question about ver 8 import / export functions

Post by Narcís » Wed May 05, 2010 7:34 am

Hi Markus,

I'm afraid not. The only alternative is using RegisterTeeSeries but it must be one by one.
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

MH3IM
Newbie
Newbie
Posts: 4
Joined: Mon May 03, 2010 12:00 am
Contact:

Re: Question about ver 8 import / export functions

Post by MH3IM » Wed May 05, 2010 9:31 am

Hi Narcís,

thank you for your quick reply! I tried it series by series but at least that leaded to just a bigger size so I decided to put the TeeEditPro to the uses clause.

But now I have just another question concerning the export and import of charts to a template. I am using the native tee-chart format for that task. Everything works fine but some properties are overwritten whenever I call the "LoadChartFromFile" function and view the chart in a TChart component. For example the Panel-Gradient property allways is checked and the background of the TChart is gradient even if it was unchecked when saving the file. When I open up a preview with a TChartPreviewer that is connected to the same TChart, the backgound is not gardient. Saving the chart again allways stores the Panel-Gradient property as checked if I do not manually uncheck it before saving.

Do you have any idea what's going wrong?

Thank you
Markus

Yeray
Site Admin
Site Admin
Posts: 9601
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Question about ver 8 import / export functions

Post by Yeray » Wed May 05, 2010 11:53 am

Hi Markus,

I'm trying the following with TeeChart VCL v2010 and I can see the same chart before and after clicking button2. Could you please modify the example so that we can reproduce the problem here?

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.Gradient.Visible:=false;

  Chart1.AddSeries(TPointSeries.Create(Self));
  Chart1[0].FillSampleValues;

  SaveChartToFile(Chart1,'C:\tmp\chart.tee');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Chart1.Free;
  Chart1:=nil;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Button1.Click;
  Chart1:=TChart.Create(Self);
  RegisterClass(TPointSeries);
  LoadChartFromFile(TCustomChart(Chart1),'C:\tmp\chart.tee');
  Chart1.Parent:=Form1;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

MH3IM
Newbie
Newbie
Posts: 4
Joined: Mon May 03, 2010 12:00 am
Contact:

Re: Question about ver 8 import / export functions

Post by MH3IM » Wed May 05, 2010 1:17 pm

Hello Yeray,

ok I tried a bit and I can reproduce the behavior. I attached a project where you can see the problem. You muss do the following:

1. Start the project
2. Uncheck then Panel-Gradient-Visible property in the chart editor
3. Close the chart editor
4. Save the chart to file by clicking the "Save" button
5. Close the application
6. Restart the application
7. Click the "Open" Button and load the file you saved in step 4

Now you should see that the gradient background is still there. If you load the file right after you saved it without closing the app the effect doesn't occur.

Regards Markus
Attachments
TChartImEx.zip
(4.71 KiB) Downloaded 853 times

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

Re: Question about ver 8 import / export functions

Post by Narcís » Thu May 06, 2010 10:08 am

Hi Markus,

Thanks for the example project. I'm afraid this is a bug which I have added to the defect list (TV52014854) to be fixed for future releases.
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

MH3IM
Newbie
Newbie
Posts: 4
Joined: Mon May 03, 2010 12:00 am
Contact:

Re: Question about ver 8 import / export functions

Post by MH3IM » Fri May 07, 2010 11:26 am

Hi Yeray,

thank you. Can I access this defect list so that I can see when the bug is fixed?

Regards
Markus

Yeray
Site Admin
Site Admin
Posts: 9601
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Question about ver 8 import / export functions

Post by Yeray » Fri May 07, 2010 11:41 am

Hi Markus,

I'm afraid we don't have a public bug tracking system. You should see if the ticket number you are interested in is in the release notes of the new release.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply