Page 1 of 1

Wrong *.tee file format in LoadChartFromStream

Posted: Thu May 17, 2012 1:26 pm
by 16460479
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

Re: Wrong *.tee file format in LoadChartFromStream

Posted: Fri May 18, 2012 9:08 am
by yeray
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;

Re: Wrong *.tee file format in LoadChartFromStream

Posted: Tue May 29, 2012 2:19 pm
by 16460479
Yes, that works! Thanks very much Yeray.