Skip to main content
All docs
V25.1
  • TdxCustomChartControl.EndUpdate Method

    Applies all pending changes and redraws the Chart control after a BeginUpdate procedure call.

    Declaration

    procedure EndUpdate;

    Remarks

    Every time you add or modify a diagram, title, or legend, or change an appearance setting value, the Chart control redraws its content to reflect the change. Enclose multiple content and appearance changes between BeginUpdate and EndUpdate procedure calls to avoid UI flickering due to excessive redraw operations and improve performance.

    BeginUpdate/EndUpdate and Batch Changes

    A BeginUpdate procedure call disables notifications and postpones all changes until an EndUpdate call. A subsequent EndUpdate call does the following:

    • Re-enables change notifications and the corresponding redraw operations
    • Applies all changes made after a BeginUpdate call
    • Sends the corresponding notifications in a batch
    • Raises the OnChange event
    • Redraws the Chart control

    Note

    Ensure that every BeginUpdate procedure call is followed by an EndUpdate or CancelUpdate procedure call, even if an exception occurs. Otherwise, the Chart control’s UI remains frozen and unresponsive.

    Code Example: Create Two Unbound Bar Series

    The following code example creates an XY diagram with two bar chart series, configures diagram and axis titles, and loads data previously saved by the SaveToStream procedure:

    uses cxDataStorage;  // 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;
    

    VCL Chart Control: An XY Diagram Example with two Bar Series

    CancelUpdate Usage Scenario – Preliminary Chart Configuration

    The EndUpdate procedure invokes the apply changes operation in the UI thread. Depending on the number of changes and available system resources, this operation may take a noticeable amount of time and render the application UI temporarily unresponsive. You can call CancelUpdate instead of the EndUpdate procedure when you need to do multiple chart changes in a batch before your application displays the Chart control to avoid unnecessary freeze-ups of the currently visible UI. The Chart control redraws its content when the first data or setting change occurs after a CancelUpdate procedure call.

    See Also