Page 1 of 1

Chart Streaming

Posted: Fri May 14, 2004 3:09 pm
by 8577282
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?

Posted: Tue May 18, 2004 10:34 am
by 8577282
Was this a stupid question?

Posted: Tue May 18, 2004 2:57 pm
by Pep
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.

Posted: Wed May 19, 2004 5:50 pm
by 8577282
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?

Posted: Thu May 20, 2004 2:02 pm
by Pep
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.