windowsforms-6596-controls-and-libraries-chart-control-examples-creating-charts-providing-data-how-to-bind-individual-chart-series-to-data.md
This tutorial demonstrates how to bind a chart to an external data source, manually add a series to the chart, and adjust its data bindings. This means that it is possible to provide an individual data source for each series.
To learn how to manually bind a chart’s series to data, do the following:
Start MS Visual Studio and create a new Windows Forms Application or open an existing one.
From the DX.25.2: Data & Analytics toolbox tab, drop the ChartControl onto the form.
To define a data source for the chart, click its smart tag, and in its actions list, expand the Choose Data Source drop-down list and click on Add Project Data Source… link.
In the Wizard’s first page, leave the data source type as Database and click Next.
In the Choose a Database Model page, click Next.
On the following page, click New Connection….
The following message will appear.
Click Next on the following page to save the created connection string to the configuration file.
Select the “Products” table as shown below and click Finish.
As a result, Visual Studio will generate a set of classes for data manipulation within the project. The main ones are:
Now, the chart has been bound to data. The next steps specify which data fields should be used to provide data for the chart’s series.
Now, let’s add series to the chart. To do this, click the chart’s smart tag and in its actions list, choose the Series… link.
In the invoked Series Collection Editor , click Add… , and select the Bar view.
Now switch to the Properties tab on the right of the editor’s window and make the following assignments for the Series1 properties:
Limit the number of data points in the series. To do this, click the SeriesBase.FilterCriteria property’s ellipsis button.
The result is illustrated in the following image.
How to: Bind Individual Chart Series to Data at Run TimeThis tutorial explains how to bind each chart series to an individual data source in code.How to: Bind Chart Series to Data in the Data Source Wizard This tutorial describes how to bind a chart to an external data source in the Data Source Configuration Wizard.How to: Specify Series Data MembersThis tutorial describes how to specify a data source for a created series, and automatically populate series points based on the data source table. See Also