Wrong *.tee file format in LoadChartFromStream

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Toreba
Newbie
Newbie
Posts: 20
Joined: Tue Oct 18, 2011 12:00 am

Wrong *.tee file format in LoadChartFromStream

Post by Toreba » Thu May 17, 2012 1:26 pm

Hi,

Using TeeChart Pro 2011.03.30407 for Delphi 2007, I am saving and a chart to stream and then later reloading from that same stream. The LoadChartFromStream call fails with the message 'Wrong *.tee file format'.

If I write the saved chart stream's DataString to file, then a call to LoadChartFromFile works fine.

Any suggestions?

Thanks very much.

Toreba

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

Re: Wrong *.tee file format in LoadChartFromStream

Post by Yeray » Fri May 18, 2012 9:08 am

Hi Toreba,

Check the stream Position is 0 before loading it.
the following example seems to work fine for me here:

Code: Select all

uses Series, TeeStore;

var stream: TMemoryStream;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with Chart1.AddSeries(TBarSeries) do
  begin
    FillSampleValues;
    ColorEachPoint:=true;
  end;
end;

procedure TForm1.SaveToStreamClick(Sender: TObject);
begin
  stream:=TMemoryStream.Create;

  SaveChartToStream(Chart1, stream);
end;

procedure TForm1.ClearChartClick(Sender: TObject);
begin
  Chart1.ClearChart;
end;

procedure TForm1.LoadFromStreamClick(Sender: TObject);
var tmpChart: TCustomChart;
begin
  if stream<>nil then
  begin
    stream.Position:=0;
    Chart1.Free;
    tmpChart:=TChart.Create(Self);
    LoadChartFromStream(tmpChart, stream);
    Chart1:=tmpChart as TChart;
    Chart1.Parent:=Self;
  end;
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

Toreba
Newbie
Newbie
Posts: 20
Joined: Tue Oct 18, 2011 12:00 am

Re: Wrong *.tee file format in LoadChartFromStream

Post by Toreba » Tue May 29, 2012 2:19 pm

Yes, that works! Thanks very much Yeray.

Post Reply