ActiveReports 6 Online Help
Chart Data
Show AllShow All
Hide AllHide All

Bound Data

The Chart control has its own data source which is distinct from the report data source. To access the chart's data source, click the Data Source verb which appears below the Properties window when the chart is selected on the report. If the Data Source verb does not appear, see Access the Chart Wizard and Data Source for help.

Unbound Data

The Chart control allows you to set the data source for a chart control, series, or data points collection at run time.

Any of the following objects can be used as data sources:

Below are some examples of binding to different data sources at run time.

Dataset

The Chart control's DataSource property can be set to a dataset at run time. The following code demonstrates how to set up a dataset, set the DataSource property to the dataset, create a series, and set the ValueMembersY property to the dataset expression at run time.

  1. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section.
  2. Add code to the handler to create a data source and bind a series to a dataset expression.

To write the code in Visual Basic.NET

To write the code in C#

Dataset Column

In the Chart control, the ValueMembersX and ValueMembersY properties of a series can be set to a dataset column. The following code demonstrates how to create a series, set up a dataset, set the DataSource property to the dataset, and set the ValueMembersY and ValueMembersX properties to dataset columns at run time.

  1. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section.
  2. Add code to the handler to create a data source and bind a series to dataset columns.

To write the code in Visual Basic.NET

To write the code in C#

Data Command

You can set a chart's data source to a SqlCommand or OleDbCommand. The following code demonstrates how to create a series, create an OleDbCommand, set the DataSource property to the data command, and set the ValueMembersY property for the series at run time.

  1. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section.
  2. Add code to the handler to create a data source and bind a series.

To write the code in Visual Basic.NET

To write the code in C#

Array

The Chart control allows you to set the data source for the data points collection to an array. The following code demonstrates how to create a series, create an array, and use the DataBindY method to set the data source for the data points collection at run time.

  1. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section.
  2. Add code to the handler to create a series, an array, and a data source.

To write the code in Visual Basic.NET

To write the code in C#

Calculated Series

You can easily create a calculated series based on the values of one or more series by setting the ValueMembersY property of a series to a formula. To reference a series in the formula, use the name of the series. The following code demonstrates how to create two series, one bound to a data array and the other bound to a formula based on the Y values of the first series.

  1. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section.
  2. Add code to the handler to create a data bound series and a calculated series.

To write the code in Visual Basic.NET

To write the code in C#

Sequence Series

Set a sequence series by specifying the minimum value, maximum value, and step for the series. The following code shows how to set the ValueMembersY property at run time to create a sequence series.

  1. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section.
  2. Add code to the handler to add a series to the chart and set its members.

To write the code in Visual Basic.NET

To write the code in C#

XML Data

The Chart control allows you to set the data source to an XML document. The following code demonstrates how to create a series and to set the ValueMembersY and ValueMemberX properties at run time.

  1. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section.
  2. Add code to the handler to add a series to the chart and set its members.

To write the code in Visual Basic.NET

To write the code in C#

 

See Also

How To

Walkthroughs