Skip to main content

VCL Charts: Doughnut View Tutorial. Step 1. Create a Doughnut Series and Bind it to Data

  • 5 minutes to read

This step describes how to add a VCL Chart control, create a doughnut series, apply a skin to the project, add and populate a memory-based dataset, and bind the created series to dataset fields at design time.

VCL Chart Control: Doughnut View Tutorial. Step 1 - The Countries Series is Visible

Add a Chart Control to the Form

Drag a VCL Chart control (TdxChartControl) from the Tool Palette onto the form. Set the control’s Align property to alClient in the Object Inspector to allow the control to occupy the form’s client area.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Add a Chart Control

Add and Configure a Skin Controller

The Skin Controller allows you to select a theme (a skin) for your application. The selected theme applies consistent look & feel across all DevExpress controls as well as standard forms.

Make sure that support for DevExpress skins is enabled for the application project. Click the Project group in the main menu of your RAD Studio® IDE and select Modify Skin Options to invoke the Project Skin Options Editor.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Project Skin Options Editor

Check Enable skin support if it is unchecked and click OK to close the Project Skin Options Editor dialog.

Add a Skin Controller to the Form

Drag a TdxSkinController component from the Tool Palette onto the form.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Add a Skin Controller

Apply a Skin

Make sure that the Skin Controller is selected. Set the NativeStyle property to False in the Object Inspector because the native (operating system-dependent) look & feel style has priority over skins and built-in basic styles.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Disable Native Style

Select a skin in the SkinName combo box in the Object Inspector.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Select any Available Skin

For example, you can select the vector skin named Basic.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Select the Basic Skin

Vector skins are recommended for high-resolution environments because vector skin elements are SVG images that DevExpress controls can render at any target monitor DPI without quality losses.

Select a Color Scheme

Each vector skin ships with a set of dark and light color schemes (color palettes). You can use the SkinPaletteName property to switch between color schemes available for the currently selected vector skin.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Select any Available Color Scheme

For example, you can select the color scheme named Violet Dark.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Select the Violet Dark Color Scheme

The Chart control’s background color changes to black as a result.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Black Chart Background

Create a Simple Diagram

The Chart control can contain one or more panes called diagrams where you can display and manage series. To display a doughnut series, you need to create a simple diagram first.

Right-click the Chart control and select the Add Simple Diagram context menu item to create an empty simple diagram.

VCL Chart Control: Doughnut View Tutorial. Step 1 - The Design-Time Context Menu

The control’s appearance does not change but now you can create a doughnut series.

Create a Doughnut Series

To create a doughnut series, right-click the Chart control and select Add Doughnut Series.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Add a Doughnut Series

The newly created empty doughnut series is displayed in the Chart control.

VCL Chart Control: Doughnut View Tutorial. Step 1 - An Empty Doughnut Series

Add and Populate a Dataset

Add a TdxMemData component to the form. This component is a memory-based dataset you can link to a data-aware control or a Chart control series in bound data access mode.

Change the component’s name to mdCountries.

Right-click the component and select Persistent Editor… in the context menu to invoke the dialog that allows you to manage dataset fields and records.

VCL Chart Control: Doughnut View Tutorial. Step 1 - The TdxMemData Component Context Menu

Follow the steps below to populate the dataset:

  1. Click Get Fields to load dataset fields from a file. Locate the Countries.dat file installed with DevExpress Demos. The default installation path is C:\Users\Public\Documents\DevExpress\VCL\Demos\ExpressCharts\Data\.
  2. Click Load… to populate dataset fields with data. Select the same file in the opened dialog.

Note

You need to install demos to use demo datasets.

The following image demonstrates the populated memory-based dataset:

VCL Chart Control: Doughnut View Tutorial. Step 1 - The Populated TdxMemData Component

Click OK to apply changes and close the Persistent Editor.

Set the TdxMemData component’s Active property to True to allow a bound control to interact with stored data.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Activate the TdxMemData Component

Bind a Series to a Data Source

Add a TDataSource component that allows you to bind a dataset to a Chart series. Rename the component to dsCountries.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Add the TDataSource Component

Configure the Data Source

Set the component’s DataSet property to mdCountries to link the data source component to the previously populated memory-based dataset.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Associate the Data Source with the Memory-Based Dataset

Bind a Series to the Data Source

Double-click the Chart control to invoke the Chart Designer dialog. Note that the active skin is applied to it.

VCL Chart Control: Doughnut View Tutorial. Step 1 - The Chart Designer Dialog

Select dxChartControl1SimpleSeries1 and rename it to Countries.

Set the DataBinding property to DB.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Enable the Bound Mode

Expand the DataBinding node in the Object Inspector and assign the dsCountries data source to the DataSource property.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Assign a Data Source

Expand the ArgumentField node and assign Country to the FieldName property.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Assign an Argument Field Name

Expand the ValueField node and assign Area to the FieldName property.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Assign a Value Field Name

The Countries series is visible as a result.

VCL Chart Control: Doughnut View Tutorial. Step 1 - The Countries Series is Visible

Tip

You can press Ctrl+H to hide non-visual components that can overlap form content at design time.

Result

The Chart control displays the Countries series with the default appearance settings. Note that the chart legend is populated with series arguments.

VCL Chart Control: Doughnut View Tutorial. Step 1 - Result

Next Step

The next step describes how to display and customize value and summary labels.

See Also