vcl-404409-expresscharts-tutorials-line-view-tutorial-vcl-charts-line-view-tutorial-bind-series-to-data.md
The previous step explained how to add a Chart control, apply a skin to the application, and create empty line series at design time. This step describes how to populate a memory-based dataset, configure a data source, and bind created series to dataset fields.
Add a TdxMemData component to the form. This component is a memory-based dataset that you can link to a data-aware control or a Chart control series in bound data access mode.
Change the component’s name to mdPopulation.
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.
Follow the steps below to populate the dataset:
Note
You need to install demos to use demo datasets.
The following image demonstrates the populated memory-based dataset:
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.
Add a TDataSource component that allows you to bind a dataset to a Chart series. Rename the component dsPopulation.
Set the component’s DataSet property to mdPopulation to link the data source component to the previously populated memory-based dataset.
Double-click the Chart control to invoke the Chart Designer dialog.
Select dxChartControl1XYSeries1 and rename it to PopulationEurope.
Set the DataBinding property to DB.
Expand the DataBinding node in the Object Inspector and assign the dsPopulation data source to the DataSource property.
Expand the ArgumentField node and set the FieldName property to Year.
Expand the ValueField node and set the FieldName property to Europe.
As a result, the Chart control displays the PopulationEurope series. Note that the chart legend automatically displays the corresponding dataset field name as a series caption.
Bind the remaining two series to data in the same manner as PopulationEurope :
DB.Year.Americas.Africa.The Chart control displays three line series as a result.
Note
You can press Ctrl + H to hide non-visual components that can overlap form content at design time.
The Chart control displays three line series with the default appearance settings. The chart legend displays the corresponding dataset field names.
The next step describes how to add and configure optional visual chart elements and customize series appearance.
See Also
VCL Charts: Line View Tutorial Overview