Skip to main content
A newer version of this page is available. .

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:

var
  AFileStream: TFileStream;
  AXYDiagram: TdxChartXYDiagram;
  AXYSeries: TdxChartXYSeries;
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');
      AXYSeries.DataBindingType := 'Unbound';  // Selects the unbound data access mode
      AXYSeries.ViewType := 'Bar';  // Selects the Bar series View
      TdxChartXYSeriesUnboundDataBinding(AXYSeries.DataBinding).ArgumentField.ValueType := 'string';
      AXYSeries.View.ValueLabels.Visible := True;  // Displays value labels on bars
      AXYSeries := AXYDiagram.AddSeries('2019');
      AXYSeries.DataBindingType := 'Unbound';  // Selects the unbound data access mode
      AXYSeries.ViewType := 'Bar';  // Selects the Bar series View
      TdxChartXYSeriesUnboundDataBinding(AXYSeries.DataBinding).ArgumentField.ValueType := 'string';
      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;

The VCL Chart Control Example with two Bar Series

See Also