Page 1 of 2

LoadFromChart / SaveToStream

Posted: Mon Jun 25, 2007 5:22 am
by 9349911
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?

Posted: Mon Jun 25, 2007 9:11 am
by yeray
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.

Posted: Mon Jun 25, 2007 9:29 am
by 9349911
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 ?!

Posted: Mon Jun 25, 2007 10:36 am
by narcis
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;

Posted: Mon Jun 25, 2007 10:59 am
by 9349911
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.

Posted: Mon Jun 25, 2007 11:26 am
by 9349911
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.

Posted: Mon Jun 25, 2007 1:36 pm
by narcis
Hi Dominik,

To achieve what you request you should manually read TMemoryStream's lines and parse them according to your needs.

Posted: Mon Jun 25, 2007 2:55 pm
by 9349911
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?

Posted: Mon Jun 25, 2007 2:59 pm
by narcis
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.

Posted: Mon Jun 25, 2007 3:11 pm
by 9349911
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

Posted: Tue Jun 26, 2007 7:22 am
by narcis
Hi Dominik,

Thanks for the information.

I've been able to reproduce this here and also added it to the defect list.

Posted: Tue Jun 26, 2007 7:31 am
by 9349911
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?

Posted: Tue Jun 26, 2007 7:44 am
by narcis
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.

Posted: Tue Jun 26, 2007 8:04 am
by 9349911
Reply only :)

Posted: Tue Jun 26, 2007 8:09 am
by narcis
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.