vcl-dxchartcore.md
The base class for all diagram classes.
TdxChartCustomDiagram = class(
TcxLockableComponent,
IdxChartVisualElement,
IdxChartCloneComponent,
IdxChartDiagram
)
A diagram is a pane designed to display and manage series in the Chart control. The TdxChartCustomDiagram class implements appearance and behavior settings common to all diagram classes.
The list below outlines key members of the TdxChartCustomDiagram class that allow you to configure diagrams and manage series in them.
TitleSpecifies the diagram title, and its position and appearance.SeriesCount | VisibleSeriesCountReturn the total number of series and the number of visible series in the diagram.Series | VisibleSeriesProvide access to visible and hidden series by their indexes.AppearanceProvides access to diagram appearance settings.IndexSpecifies the diagram’s index in the Chart control.VisibleSpecifies if the Chart control displays the diagram and its visible series.LegendProvides access to the diagram’s legend pane settings.BeginUpdate | EndUpdate | CancelUpdateAllow you to avoid excessive redraw operations during batch data and appearance setting changes.DeleteAllSeriesDeletes all series in the diagram.OnGetSeriesPointDrawParameters | OnGetValueLabelDrawParametersAllow you to customize individual series points and value labels.AssignCopies compatible settings between diagrams.
A Chart control’s Diagrams and VisibleDiagrams properties reference created diagrams as TdxChartCustomDiagram objects. Cast them to the following descendants to access all diagram type-specific properties and methods:
A diagram designed to display series using the axis of arguments (X-axis) and the axis of values (Y-axis). An XY diagram can plot Area, Bar, and Line series.
A diagram intended to plot Pie and Doughnut series.
The following code example creates an XY diagram with two Bar chart series and populates them with data in unbound mode:
uses cxDataStorage; // Declares the TcxStringValueType class
// ...
var
AXYDiagram: TdxChartXYDiagram;
AXYSeries: TdxChartXYSeries;
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';
AXYSeries := AXYDiagram.AddSeries('2018'); // Creates a new XY series with the caption "2018"
AXYSeries.DataBindingClass := TdxChartXYSeriesUnboundDataBinding; // Selects the unbound data access mode
ADataBinding := AXYSeries.DataBinding as TdxChartXYSeriesUnboundDataBinding;
ADataBinding.ArgumentField.ValueTypeClass := TcxStringValueType; // Selects the string data type
AXYSeries.ViewClass := TdxChartXYSeriesBarView; // Selects the Bar series View
AXYSeries.Points.Add('Asia', 4.2372);
AXYSeries.Points.Add('Australia', 1.7871);
AXYSeries.Points.Add('Europe', 3.0884);
AXYSeries.Points.Add('North America', 3.4855);
AXYSeries.Points.Add('South America', 1.6027);
AXYSeries.View.ValueLabels.Visible := True; // Displays value labels on bars
AXYSeries := AXYDiagram.AddSeries('2019'); // Creates a new XY series with the caption "2019"
AXYSeries.DataBindingClass := TdxChartXYSeriesUnboundDataBinding; // Selects the unbound data access mode
ADataBinding := AXYSeries.DataBinding as TdxChartXYSeriesUnboundDataBinding;
ADataBinding.ArgumentField.ValueTypeClass := TcxStringValueType; // Selects the string data type
AXYSeries.ViewClass := TdxChartXYSeriesBarView; // Selects the Bar series View
AXYSeries.Points.Add('Asia', 4.7685);
AXYSeries.Points.Add('Australia', 1.9576);
AXYSeries.Points.Add('Europe', 3.3579);
AXYSeries.Points.Add('North America', 3.7477);
AXYSeries.Points.Add('South America', 1.8237);
AXYSeries.View.ValueLabels.Visible := True; // Displays value labels on bars
finally
dxChartControl1.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
#include "cxDataStorage.hpp" // Declares the TcxStringValueType class
// ...
TdxChartXYDiagram *AXYDiagram;
TdxChartXYSeries *AXYSeries;
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";
AXYSeries = AXYDiagram->AddSeries("2018"); // Creates a new XY series with the caption "2018"
// Selects the unbound data access mode
AXYSeries->DataBindingClass = __classid(TdxChartXYSeriesUnboundDataBinding);
AXYSeries->ViewClass = __classid(TdxChartXYSeriesBarView); // Selects the Bar series View
ADataBinding = dynamic_cast<TdxChartXYSeriesUnboundDataBinding*>(AXYSeries->DataBinding);
// Selects the string data type for arguments
ADataBinding->ArgumentField->ValueTypeClass = __classid(TcxStringValueType);
AXYSeries->Points->Add("Asia", 4.2372);
AXYSeries->Points->Add("Australia", 1.7871);
AXYSeries->Points->Add("Europe", 3.0884);
AXYSeries->Points->Add("North America", 3.4855);
AXYSeries->Points->Add("South America", 1.6027);
AXYSeries->View->ValueLabels->Visible = true; // Displays value labels on bars
AXYSeries = AXYDiagram->AddSeries("2019"); // Creates a new XY series with the caption "2019"
// Selects the unbound data access mode
AXYSeries->DataBindingClass = __classid(TdxChartXYSeriesUnboundDataBinding);
AXYSeries->ViewClass = __classid(TdxChartXYSeriesBarView); // Selects the Bar series View
ADataBinding = dynamic_cast<TdxChartXYSeriesUnboundDataBinding*>(AXYSeries->DataBinding);
// Selects the string data type for arguments
ADataBinding->ArgumentField->ValueTypeClass = __classid(TcxStringValueType);
AXYSeries->Points->Add("Asia", 4.7685);
AXYSeries->Points->Add("Australia", 1.9576);
AXYSeries->Points->Add("Europe", 3.3579);
AXYSeries->Points->Add("North America", 3.7477);
AXYSeries->Points->Add("South America", 1.8237);
AXYSeries->View->ValueLabels->Visible = true; // Displays value labels on bars
}
__finally
{
dxChartControl1->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
// ...
To delete a diagram, release it directly in code (call the Free procedure in Delphi or use the delete keyword in C++Builder).
TObject TPersistent TComponent TcxLockableComponent TdxChartCustomDiagram
See Also