Back to Devexpress

TdxChartSimpleSeries Class

vcl-dxchartsimplediagram-30f88dc2.md

latest11.5 KB
Original Source

TdxChartSimpleSeries Class

A series in a simple diagram.

Declaration

delphi
TdxChartSimpleSeries = class(
    TdxChartCustomSeries
)

Remarks

Simple series display values as portions of a shape, such as a pie or doughnut. Simple series are useful when you need to compare percentage values of different point arguments in the same series.

Supported Simple Series Views

A series View determines how a simple diagram displays series.[1] A diagram can display multiple series with different Views and individual View appearance settings. You can use the ViewType or ViewClass property to switch between compatible Views in any existing series and display the same data in a different manner at any time.

Pie View

The Pie View displays series values as slices of a circle whose radial angles reflect shares of all series values in relation to their total.

Doughnut View

The Doughnut View is identical to the Pie View but has a hole in its center.

Main API Members

The list below outlines key members of the TdxChartSimpleSeries class that allow you to configure series.

Appearance and Behavior Settings

Caption | TitleSpecify series caption and title.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.ViewClass | ViewTypeSwitch between available View types.ViewProvides access to the active series View settings.

Data-Related Settings

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.TopNOptionsSpecifies how the series determines points with highest or lowest values and displays them.

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 an Unbound Doughnut Series

The following code example creates a simple series with the Doughnut View and populates it with data points in unbound mode:

delphi
uses cxDataStorage; // Declares the TcxStringValueType class
// ...
var
  ASimpleDiagram: TdxChartSimpleDiagram;
  ASimpleSeries: TdxChartSimpleSeries;
  ADoughnutView: TdxChartSimpleSeriesDoughnutView;
  ADataBinding: TdxChartSimpleSeriesUnboundDataBinding;
begin
  dxChartControl1.BeginUpdate; // Initiates the following batch change
  try
    ASimpleDiagram := dxChartControl1.AddDiagram<TdxChartSimpleDiagram>('Country statistics');
    ASimpleDiagram.Title.Appearance.FontOptions.Size := 16;
    ASimpleDiagram.Legend.AlignmentHorz := TdxChartLegendAlignment.Near; // Moves the legend pane
    ASimpleSeries := ASimpleDiagram.AddSeries('Area'); // Creates a simple series
    // Displays series data point arguments on the diagram legend pane
    ASimpleSeries.ShowInLegend := TdxChartSeriesShowInLegend.Diagram;
    ASimpleSeries.ViewClass := TdxChartSimpleSeriesDoughnutView; // Selects the Doughnut series View
    // Selects the unbound data access mode
    ASimpleSeries.DataBindingClass := TdxChartSimpleSeriesUnboundDataBinding;
    ADataBinding := ASimpleSeries.DataBinding as TdxChartSimpleSeriesUnboundDataBinding;
    ADataBinding.ArgumentField.ValueTypeClass := TcxStringValueType; // Selects the string data type
    ASimpleSeries.Title.Text := 'Area'; // Specifies the series title
    // Populates the unbound simple series with data points
    ASimpleSeries.Points.Add('Russia', 17.0752);
    ASimpleSeries.Points.Add('Canada', 9.98467);
    ASimpleSeries.Points.Add('USA', 9.63142);
    ASimpleSeries.Points.Add('China', 9.59696);
    ASimpleSeries.Points.Add('Brazil', 8.511965);
    ASimpleSeries.Points.Add('Australia', 7.68685);
    ASimpleSeries.Points.Add('India', 3.28759);
    ASimpleSeries.Points.Add('Others', 81.2);
    // Customizes appearance of the Doughnut series View
    ADoughnutView := ASimpleSeries.View as TdxChartSimpleSeriesDoughnutView;
    ADoughnutView.HoleRadius := 50;
    ADoughnutView.ExplodedValueOptions.Mode := TdxChartExplodedValueMode.All;
  finally
    dxChartControl1.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
  end;
cpp
#include "cxDataStorage.hpp" // Declares the TcxStringValueType class
// ...
  TdxChartSimpleDiagram *ASimpleDiagram;
  TdxChartSimpleSeries *ASimpleSeries;
  TdxChartSimpleSeriesDoughnutView *ADoughnutView;
  TdxChartSimpleSeriesUnboundDataBinding *ADataBinding;
  // ...
  dxChartControl1->BeginUpdate(); // Initiates the following batch change
  try
  {
    ASimpleDiagram = new TdxChartSimpleDiagram(dxChartControl1->Owner);
    ASimpleDiagram->SetParentComponent(dxChartControl1);
    ASimpleDiagram->Title->Text = "Country Statistics";
    ASimpleDiagram->Title->Appearance->FontOptions->Size = 16;
    ASimpleDiagram->Legend->AlignmentHorz = TdxChartLegendAlignment::Near; // Moves the legend pane
    ASimpleSeries = ASimpleDiagram->AddSeries("Area"); // Creates a simple series
    // Displays series data point arguments on the diagram legend pane
    ASimpleSeries->ShowInLegend = TdxChartSeriesShowInLegend::Diagram;
    // Selects the Doughnut series View
    ASimpleSeries->ViewClass = __classid(TdxChartSimpleSeriesDoughnutView);
    // Selects the unbound data access mode
    ASimpleSeries->DataBindingClass = __classid(TdxChartSimpleSeriesUnboundDataBinding);
    ADataBinding = dynamic_cast<TdxChartSimpleSeriesUnboundDataBinding*>(ASimpleSeries->DataBinding);
    ADataBinding->ArgumentField->ValueTypeClass = TcxStringValueType; // Selects the string data type
    ASimpleSeries->Title->Text = "Area"; // Specifies the series title
    // Populates the unbound simple series with data points
    ASimpleSeries->Points->Add("Russia", 17.0752);
    ASimpleSeries->Points->Add("Canada", 9.98467);
    ASimpleSeries->Points->Add("USA", 9.63142);
    ASimpleSeries->Points->Add("China", 9.59696);
    ASimpleSeries->Points->Add("Brazil", 8.511965);
    ASimpleSeries->Points->Add("Australia", 7.68685);
    ASimpleSeries->Points->Add("India", 3.28759);
    ASimpleSeries->Points->Add("Others", 81.2);
    // Customizes appearance of the Doughnut series View
    ADoughnutView = dynamic_cast<TdxChartSimpleSeriesDoughnutView*>(ASimpleSeries->View);
    ADoughnutView->HoleRadius = 50;
    ADoughnutView->ExplodedValueOptions->Mode = TdxChartExplodedValueMode::All;
  }
  __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).

To see a simple series in action, run the Chart Control demo in the VCL Demo Center installed with compiled DevExpress VCL demos. Select Pie or Doughnut in the left sidebar.

Download: Compiled VCL Demos

Tip

Compiled DevExpress demos ship with source code installed in the Public Documents folder (%Public%) for all users ( default ). You can find all project and source code files for the Chart control in the following folder:

%Public%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressChart

Direct TdxChartSimpleSeries Class Reference

The following public API members reference a TdxChartSimpleSeries object:

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

Inheritance

TObject TPersistent TComponent TcxLockableComponent TdxChartCustomSeries TdxChartSimpleSeries

Footnotes

  1. All example images in this topic section demonstrate the same series when different Views are active for comparison.

See Also

TdxChartXYSeries Class

TdxChartSimpleSeries Members

dxChartSimpleDiagram Unit