TdxCustomChartControl.LoadFromStream(TStream) Method
Loads series data from the specified stream populated by a SaveToStream procedure call.
Declaration
procedure LoadFromStream(AStream: TStream);
Parameters
Name | Type | Description |
---|---|---|
AStream | TStream | The source stream with series data. |
Remarks
Call the LoadFromStream
procedure to load all series data from all diagrams that the Chart control has at the moment of the SaveToStream procedure call that created the specified source data stream.
Important
The SaveToStream procedure saves only series data, and the resulting stream does not include information about the Chart control layout, diagrams, and their series. You need to store this information separately.
Example
The following code example creates an XY diagram with two Bar chart series, configures diagram and axis titles, and loads data previously saved by a SaveToStream procedure call:
uses cxDataStorage; // This unit declares the TcxStringValueType class
// ...
var
AFileStream: TFileStream;
AXYDiagram: TdxChartXYDiagram;
AXYSeries: TdxChartXYSeries;
ADataBinding: TdxChartXYSeriesUnboundDataBinding;
begin
dxChartControl1.BeginUpdate; // Initiates the following batch change
try
AFileStream := TFileStream.Create('DevAVSales.dat', fmOpenRead);
try
AXYDiagram := dxChartControl1.AddDiagram<TdxChartXYDiagram>('DevAV Sales by Region');
AXYDiagram.Title.Appearance.FontOptions.Size := 20;
AXYDiagram.Axes.AxisY.Title.Text := 'Millions of Dollars';
AXYSeries := AXYDiagram.AddSeries('2018');
// Selects the unbound data access mode
AXYSeries.DataBindingClass := TdxChartXYSeriesUnboundDataBinding;
AXYSeries.ViewClass := TdxChartXYSeriesBarView; // Selects the Bar series View
ADataBinding := AXYSeries.DataBinding as TdxChartXYSeriesUnboundDataBinding;
ADataBinding.ArgumentField.ValueTypeClass := TcxStringValueType; // Selects the string data type
AXYSeries.View.ValueLabels.Visible := True; // Displays value labels on bars
AXYSeries := AXYDiagram.AddSeries('2019');
// Selects the unbound data access mode
AXYSeries.DataBindingClass := TdxChartXYSeriesUnboundDataBinding;
AXYSeries.ViewClass := TdxChartXYSeriesBarView; // Selects the Bar series View
ADataBinding := AXYSeries.DataBinding as TdxChartXYSeriesUnboundDataBinding;
ADataBinding.ArgumentField.ValueTypeClass := TcxStringValueType; // Selects the string data type
AXYSeries.View.ValueLabels.Visible := True; // Displays value labels on bars
dxChartControl1.LoadFromStream(AFileStream);
finally
AFileStream.Free; // Releases the file stream regardless of the data load operation's success
end;
finally
dxChartControl1.EndUpdate; // Calls EndUpdate regardless of the batch change's success
end;
end;
See Also