Back to Devexpress

TdxChartCustomSeries Class

vcl-dxchartcore-cedeb971.md

latest12.9 KB
Original Source

TdxChartCustomSeries Class

The base class for all chart series classes.

Declaration

delphi
TdxChartCustomSeries = class(
    TcxLockableComponent,
    IdxChartLegendItem,
    IdxChartCloneComponent
)

Remarks

A series is a set of data points displayed in a diagram. The TdxChartCustomSeries class implements appearance and behavior settings common to all series classes. Common settings include data binding modes and a data point collection.

Available Series Types

A diagram’s Series and VisibleSeries properties reference created series as TdxChartCustomSeries objects. Cast them to the following descendant classes to access all series type-specific properties and methods:

TdxChartXYSeries

A series compatible with XY diagrams designed to display data using the axis of arguments and the axis of values. An XY series supports Area, Bar, and Line Views.

TdxChartSimpleSeries

A series compatible with simple diagrams with support for Pie and Doughnut Views.

Main API Members

The list below outlines key members of the TdxChartCustomSeries class. These members allow you to configure series.

Appearance and Behavior

CaptionSpecifies the series caption.CheckableInLegendSpecifies if users can hide or display the XY series in the chart legend.EmptyPointsDisplayModeSpecifies how the Chart control displays empty points in the series.IndexSpecifies the index of the series in its diagram.StoredNameSpecifies the custom name for saving series data to a stream.Title

Specifies the series title, and its appearance and position in the parent diagram.

Note

Only the TdxChartSimpleSeries class publishes this property because an XY diagram layout has no dedicated positions for individual series titles.

ToolTipsProvides access to series tooltip settings.ViewClass | ViewTypeSwitch between available View types.ViewProvides access to the active series View settings.

Data Binding and Shaping Options

DataBindingClass | DataBindingTypeSwitch between data access modes.DataBindingProvides access to data binding settings.PointsProvides access to the series point collection.SortBy | SortOrderSort data points by values or arguments in ascending or descending order.TopNOptions

Allows you to limit the number of series points displayed as individual slices.

Note

Only the TdxChartSimpleSeries class publishes this property.

General-Purpose API Members

AssignFromUpdates all series settings from the specified source.BeginUpdate | EndUpdate | CancelUpdateAllow you to avoid excessive redraw operations during batch data and appearance changes.DiagramSpecifies the diagram to which the series belongs.

Code Example: Create Three Unbound Stacked Bar Series

The following code example creates three stacked bar series with identical appearance settings in unbound data access mode:

delphi
uses cxDataStorage; // Declares the TcxStringValueType class
// ...
var
  AXYDiagram: TdxChartXYDiagram;
  AXY2018Series, AXY2019Series, AXY2020Series: TdxChartXYSeries;
  AStackedBarView: TdxChartXYSeriesStackedBarView;
  ADataBinding: TdxChartXYSeriesUnboundDataBinding;
begin
  dxChartControl1.BeginUpdate; // Initiates the following batch change
  try
    AXYDiagram := dxChartControl1.AddDiagram<TdxChartXYDiagram>('DevAV Sales By Region');
    AXYDiagram.Title.Appearance.FontOptions.Size := 20;
    AXYDiagram.Axes.AxisY.Title.Text := 'Millions of Dollars';
    AXYDiagram.Axes.AxisY.Title.Appearance.FontOptions.Size := 14;
    AXY2018Series := AXYDiagram.AddSeries('2018'); // Creates a new series with the caption "2018"
    // Selects the unbound data access mode
    AXY2018Series.DataBindingClass := TdxChartXYSeriesUnboundDataBinding;
    ADataBinding := AXY2018Series.DataBinding as TdxChartXYSeriesUnboundDataBinding;
    // Selects the string data type for arguments
    ADataBinding.ArgumentField.ValueTypeClass := TcxStringValueType;
    AXY2018Series.ViewClass := TdxChartXYSeriesStackedBarView; // Selects the Stacked Bar series View
    AStackedBarView := AXY2018Series.View as TdxChartXYSeriesStackedBarView;
    AStackedBarView.ValueLabels.Visible := True; // Displays value labels on bars
    AStackedBarView.ValueLabels.TextFormat := '{V:0.000}'; // Changes the number display format
    AStackedBarView.ValueLabels.Appearance.FontOptions.Bold := True;
    AXY2018Series.Points.Add('Asia', 4.2372);
    AXY2018Series.Points.Add('Australia', 1.7871);
    AXY2018Series.Points.Add('Europe', 3.0884);
    AXY2018Series.Points.Add('North America', 3.4855);
    AXY2018Series.Points.Add('South America', 1.6027);
    AXY2019Series := AXYDiagram.AddSeries; // Creates a new series with the default settings
    AXY2019Series.AssignFrom(AXY2018Series); // Copies all settings from the "2018" series
    AXY2019Series.Caption := '2019'; // Defines a different series caption
    AXY2019Series.Points.Add('Asia', 4.7685);
    AXY2019Series.Points.Add('Australia', 1.9576);
    AXY2019Series.Points.Add('Europe', 3.3579);
    AXY2019Series.Points.Add('North America', 3.7477);
    AXY2019Series.Points.Add('South America', 1.8237);
    AXY2020Series := AXYDiagram.AddSeries('2020'); // Creates a new series with the default settings
    AXY2020Series.AssignFrom(AXY2018Series); // Copies all settings from the "2018" series
    AXY2020Series.Caption := '2020'; // Defines a different series caption
    AXY2020Series.Points.Add('Asia', 5.289);
    AXY2020Series.Points.Add('Australia', 2.2727);
    AXY2020Series.Points.Add('Europe', 3.7257);
    AXY2020Series.Points.Add('North America', 4.1825);
    AXY2020Series.Points.Add('South America', 2.1172);
  finally
    dxChartControl1.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
  end;
end;
cpp
#include "cxDataStorage.hpp" // Declares the TcxStringValueType class
// ...
  TdxChartXYDiagram *AXYDiagram;
  TdxChartXYSeries *AXY2018Series, *AXY2019Series, *AXY2020Series;
  TdxChartXYSeriesStackedBarView *AStackedBarView;
  TdxChartXYSeriesUnboundDataBinding *ADataBinding;
  // ...
  dxChartControl1->BeginUpdate(); // Initiates the following batch change
  try
  {
    AXYDiagram = new TdxChartXYDiagram(dxChartControl1->Owner);
    AXYDiagram->SetParentComponent(dxChartControl1);
    AXYDiagram->Title->Text = "DevAV Sales by Region";
    AXYDiagram->Title->Appearance->FontOptions->Size = 20;
    AXYDiagram->Axes->AxisY->Title->Text = "Millions of Dollars";
    AXYDiagram->Axes->AxisY->Title->Appearance->FontOptions->Size = 14;
    AXYSeries = AXYDiagram->AddSeries("2018"); // Creates a new series with the caption "2018"
    // Selects the unbound data access mode
    AXYSeries->DataBindingClass = __classid(TdxChartXYSeriesUnboundDataBinding);
    ADataBinding = dynamic_cast<TdxChartXYSeriesUnboundDataBinding*>(AXY2018Series->DataBinding);
    // Selects the string data type for arguments
    ADataBinding->ArgumentField->ValueTypeClass = __classid(TcxStringValueType);
    // Selects the Stacked Bar series View
    AXYSeries->ViewClass = __classid(TdxChartXYSeriesStackedBarView);
    AStackedBarView = dynamic_cast<TdxChartXYSeriesStackedBarView*>(AXY2018Series->View);
    AStackedBarView->ValueLabels->Visible = true; // Displays value labels on bars
    AStackedBarView->ValueLabels->TextFormat = "{V:0.000}"; // Changes the number display format
    AStackedBarView->ValueLabels->Appearance->FontOptions->Bold = true;
    AXY2018Series->Points->Add("Asia", 4.2372);
    AXY2018Series->Points->Add("Australia", 1.7871);
    AXY2018Series->Points->Add("Europe", 3.0884);
    AXY2018Series->Points->Add("North America", 3.4855);
    AXY2018Series->Points->Add("South America", 1.6027);
    AXY2019Series = AXYDiagram->AddSeries(); // Creates a new series with the default settings
    AXY2019Series->AssignFrom(AXY2018Series); // Copies all settings from the "2018" series
    AXY2019Series->Caption = "2019"; // Defines a different series caption
    AXY2019Series->Points->Add("Asia", 4.7685);
    AXY2019Series->Points->Add("Australia", 1.9576);
    AXY2019Series->Points->Add("Europe", 3.3579);
    AXY2019Series->Points->Add("North America", 3.7477);
    AXY2019Series->Points->Add("South America", 1.8237);
    AXY2020Series = AXYDiagram->AddSeries(); // Creates a new series with the default settings
    AXY2020Series->AssignFrom(XY2018Series); // Copies all settings from the "2018" series
    AXY2020Series->Caption = "2020"; // Defines a different series caption
    AXY2020Series->Points->Add("Asia", 5.289);
    AXY2020Series->Points->Add("Australia", 2.2727);
    AXY2020Series->Points->Add("Europe", 3.7257);
    AXY2020Series->Points->Add("North America", 4.1825);
    AXY2020Series->Points->Add("South America", 2.1172);
  }
  __finally
  {
    dxChartControl1->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
  }
  // ...

Series Deletion

To delete all series in a diagram, call its DeleteAllSeries procedure. To delete an individual series, release it directly in code (call the Free procedure in Delphi or use the delete keyword in C++Builder).

Direct TdxChartCustomSeries Class References

The following public API members reference a TdxChartCustomSeries object:

TdxChartCustomDiagram.SeriesProvides indexed access to all series in the diagram.TdxChartCustomDiagram.VisibleSeriesProvides indexed access to all visible series in the diagram.

Implements

IdxChartLegendItem

Inheritance

TObject TPersistent TComponent TcxLockableComponent TdxChartCustomSeries

See Also

TdxChartCustomSeries Members

dxChartCore Unit