LoadFromChart / SaveToStream

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

LoadFromChart / SaveToStream

Post by moelski » Mon Jun 25, 2007 5:22 am

Hi !

We are using LoadFromChart and SaveToStream to use TChart with streams. For loading we use this code:

Code: Select all

LoadChartFromStream(TCustomChart(Form1.MainChart), LogStream.DataSet[DatensatzIdx].Chart_Stream);
and for saving we use this code:

Code: Select all

SaveChartToStream( MainChart,
                       TStream(DatenStream[PresentDevice.AktuellerKanal].DataSet[_DataSetIndex].Chart_Stream),
                       False, True);
This works fine in most cases. But there are some properties which are not restored after you load a stream. For example the complete 3D section is not present after loading from the stream. You save a 3D chart and always get a 2D Chart back.

We saved the stream to our logging software and take a look to the hex values. The 3D options are definitely in the stream.

So what must we do to save and load the complete Chartstream?

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

Post by Yeray » Mon Jun 25, 2007 9:11 am

We couldn't reproduce the issue here, using lastest release (v8 "available at the web").

Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
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

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Mon Jun 25, 2007 9:29 am

Hi Yeray,

I´ve just upload a file to the server:
"Received StreamHandling.zip Content Type application/x-zip-compressed Length 37890"

Use the button "Stream" to copy the Chart as stream from Chart left to chart right. If you use "File" it is copied by using SaveChartToFile, LoadChartFromFile.

In both cases there are some properties gone. For example the 3D settings are completely away.

The interesting thing ... If you are using your TChartOffice to load the export.tee file, it is shown in the corect was including 3D options.

Maybe I´m duing something generally wrng with implementing LoadChartFromStream and SaveChartToStream ?!

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 Jun 25, 2007 10:36 am

Hi Dominik,

Thanks for your project, we have been able to reproduce the problem here and it is because original chart is in 3D and destination chart in 2D. Since default view is 3D this property is not saved in the template file/stream unless changed by the user.

I'll add this to our wish-list to be enhanced for future releases. In the meantime a workaround is doing something like this:

Code: Select all

uses TeeStore, TeeEditPro;

procedure TForm1.FormCreate(Sender: TObject);
var stream: TMemoryStream;
begin
  stream:=TMemoryStream.Create;
  try
    SaveChartToStream(Chart1,stream);
    stream.Position:=0;
    LoadChartFromStream(TCustomChart(Chart2),stream);
  finally
    stream.Free;
  end;

  Chart2.Left:=Chart1.Left+Chart1.Width;
  Chart2.View3D:=Chart1.View3D;
//  Chart2.Aspect:=Chart1.Aspect;
end;
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

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Mon Jun 25, 2007 10:59 am

Hi Narcís,

well the 3D part works now. Ok.

But there are For example: If you add a legend to the chart, it is not shown in the other one.
It seems to me that not all properties from the original chart are saved into the stream.

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Mon Jun 25, 2007 11:26 am

Hi Narcís,

one additional question ...
How can I read values from a ChartStream ?

Lets say I have this code:

Code: Select all

  ChartSave := TMemoryStream.Create;
  SaveChartToStream(Chart1, ChartSave, True, False);
Is it possible to read some properties directly from the Stream like the width / height of the chart or the Settings for 3D and / or legend?

Something like ths won´t work :
Test := ChartSave.Top;
That´s ok because ChartSave is only a TMemoryStream.

But maybe there is a solution for this? This would help us a lot to switch on the correct settings to the new chart.

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 Jun 25, 2007 1:36 pm

Hi Dominik,

To achieve what you request you should manually read TMemoryStream's lines and parse them according to your needs.
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

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Mon Jun 25, 2007 2:55 pm

Hi Narcís,

ok!

And what did you say to the not working legend after LoadFromstream?
Is it the same problem like the 3D options?

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 Jun 25, 2007 2:59 pm

Hi Dominik?

What do you exactly mean, adding an extra legend tool at the original chart? This works fine for me here.

Thanks in advance.
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

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Mon Jun 25, 2007 3:11 pm

Hi !

Use my demo.
Add a Legend to the chart on the left side and no legend to the chart at the right.
Press Stream button and there is no legend at the right chart.

I think it is the same prob as with the 3D options, isn´t it?

Greetz

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 Jun 26, 2007 7:22 am

Hi Dominik,

Thanks for the information.

I've been able to reproduce this here and also added it to the defect list.
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

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Tue Jun 26, 2007 7:31 am

Hi Narcis,

Ok.

At the moment we use a special boolean value to check is the legend was enabled. So it works for us. But it would be great if u fix it in the future.

btw:
Why didn´t I get any mails if someone writes an answer to a posting?

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 Jun 26, 2007 7:44 am

Hi Dominik,
btw:
Why didn´t I get any mails if someone writes an answer to a posting?
It's strange, for now nobody complained from this. Maybe the automatic e-mails were trapped by your anti-spam filter or something similar. Now I enabled this option for this thread, could you please post a reply so that I can check if I receive the notification?

Thanks in advance.
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

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Tue Jun 26, 2007 8:04 am

Reply only :)

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 Jun 26, 2007 8:09 am

Hi Dominik,

Thanks for your collaboration.

I receive the reply notification so I guess it must be something with your firewall or anti-spam filters. Could you please check that no e-mails get blocked there?

Thanks in advance.
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

Post Reply