ComponentOne FlexChart for WinForms
Binding Data to FlexChart
FlexChart > Working with FlexChart > Data > Providing Data > Binding Data Using a Data Source > Binding Data to FlexChart

Data is bound to FlexChart through the following steps: setting the DataSource property and setting the BindingX and the Binding property.

Step 1: Setting the DataSource property

At Design-Time

Set the DataSource property at design-time by performing the following steps:

  1. Select FlexChart from the Properties window.
  2. Select the desired data source from the DataSource property drop-down list box.

           

In Code

Set the DataSource property by using the following code:

FlexChart1.DataSource = bindingSource1
flexChart1.DataSource = bindingSource1;
You can set the DataSource property both at the chart level and at the series level. To set the property at the series level, navigate to Series in the Properties window. Click the Ellipsis button and open Series Collection Editor. Then, navigate to the DataSource property, and select the relevant data source from the drop-down list box.

Step 2: Setting the BindingX and the Binding property

Once you have set the DataSource property, you need to specify the fields to apply to the data series in the chart. In simple terms, you need to specify the fields to set data values for primary X and Y arrays and also for secondary Y arrays (depending upon the chart type).

You need to set the BindingX property to the field containing X values and the Binding property to the field(s) containing Y values.

At Design-Time

Perform the following steps:

  1. Navigate to the BindingX and the Binding property.
  2. Select the desired field from the BindingX drop-down list box to bind to X data array.
  3. Select the desired field from the Binding drop-down list box to bind to Y data array.

In Code

Use the following code to set the BindingX and the Binding property at run-time:

FlexChart1.BindingX = "Id"
series1.Binding = "Sum"
series2.Binding = "Cost"
flexChart1.BindingX = "Id";
series1.Binding = "Sum";
series2.Binding = "Cost";

Like the DataSource property, you can set the Binding X and the Binding property at the chart as well as the series level. To set the properties at the series level, navigate to Series in the Properties window and click the Ellipsis button next to Series. In Series Collection Editor, navigate to the BindingX and the Binding property. Then, select the appropriate fields from the drop-down list box of the properties.