Chart Streaming

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Gilbert
Newbie
Newbie
Posts: 14
Joined: Thu Jul 10, 2003 4:00 am
Location: Johannesburg

Chart Streaming

Post by Gilbert » Fri May 14, 2004 3:09 pm

Are all published values of a chart streamed with SaveChartToStream? I switched on Left and Bottom axis grid lines at runtime, saved the chart to stream, re-loaded the stream into another chart and gridlines where gone. How do i verify the contents of the outgoing stream - is there a way to get a text (dfm-style) representation of the chart, or is it a proprietry format?

Gilbert
Newbie
Newbie
Posts: 14
Joined: Thu Jul 10, 2003 4:00 am
Location: Johannesburg

Post by Gilbert » Tue May 18, 2004 10:34 am

Was this a stupid question?

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue May 18, 2004 2:57 pm

Hi Gilbert,
Are all published values of a chart streamed with SaveChartToStream? I switched on Left and Bottom axis grid lines at runtime, saved the chart to stream, re-loaded the stream into another chart and gridlines where gone.
Yes, if you want to save all the settings you'll have to use SaveChartToFile or SaveChartToStream method to save chart (with or without data) and then use LoadChartFromFile or LoadChartFromStream method to load chart "settings".
I've tried with the folloiwng code and works fine here (using the latest TeeChart Pro v7) , all grid pen style is saved, could you please test if it works for you ?

Code: Select all

Uses TeeStore, EditChar;
{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(10);
Chart1.Axes.Left.Grid.Style := psSolid;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
Begin
memStream := TMemoryStream.Create;
SaveChartToStream(Chart1,memStream,true,true);
Chart1.RemoveAllSeries;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
memStream.Position := 0;
Chart2.AutoRepaint := False;
LoadChartFromStream(tCustomChart(Chart1),memStream);
end;
How do i verify the contents of the outgoing stream - is there a way to get a text (dfm-style) representation of the chart, or is it a proprietry format?
You can save the stream or file as text, setting to true the last parameter of the methods.

Gilbert
Newbie
Newbie
Posts: 14
Joined: Thu Jul 10, 2003 4:00 am
Location: Johannesburg

Post by Gilbert » Wed May 19, 2004 5:50 pm

That's all cool, stream is saving properly, but - default values are not saved to stream. So, it seems, that when the chart is streamed in, values not in the stream are not set, hence my problem:
Gridlines is True by default.
I am streaming onto a chart where Gridlines is False and, since the property is not in the stream, it is not changed.
Since i cannot reset all default properties in the chart before streaming, here is a workaround:

procedure TFrameChart.SetupLayout(Layout: string);
var
ssTemp : TStringStream;
tcTemp : TCustomChart;
begin
if (Trim(Layout) <> EMPTY_STRING) then
begin
ssTemp := TStringStream.Create(Layout);
try
tcTemp := TDBChart.Create(Self);
try
LoadChartFromStream(tcTemp, ssTemp);
tcChart.Assign(tcTemp);
finally
tcTemp.Free;
end;
AssignEvents;
finally
ssTemp.Free;
end;
end;
end;

The AssignEvents procedure also seems to be neccessary - i have to set all fixed events to nil before streaming out as, when the chart is streamed in, having events causes some kind of Invalid Property error. Is there something I am doing wrong?

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu May 20, 2004 2:02 pm

Hi Gilbert,
The AssignEvents procedure also seems to be neccessary - i have to set all fixed events to nil before streaming out as, when the chart is streamed in, having events causes some kind of Invalid Property error. Is there something I am doing wrong?
No, this is by default, the events are not saved, you've done the correct steps, set all the events to nil before export the Chart and then reasign all again when the Chart is imported.

Post Reply