2D Chart for WinForms | ComponentOne
Chart for WinForms Quick Start / Step 2 of 4: Bind C1Chart to the Data Source
In This Topic
    Step 2 of 4: Bind C1Chart to the Data Source
    In This Topic

    To bind your chart to the data source that you created in the previous step, complete the following tasks:

    1. From the Toolbox, double-click the C1Chart control to add it to the form. Resize the C1Chart control to be around 400x400.
    2. Right-click on the chart and select Chart Properties from the menu. The Chart Properties designer appears.
    3. Click Gallery, select the Simple Types tab, and then select select Bar. In the right pane select the first bar image in the first row, and click Apply.
    4. Click Data and select Series 3. Click Remove to remove Series 3 from the bar chart.
    5. Label Series 0 as Unit Price, Series 1 as Units in Stock, and Series 2 as Reorder Level. Click Apply.
    6. In the tree view, select Data>Binding, and select dataView1 from the Data source drop-down list -box.
    7. Click on Data and select the Unit Price from the Data Series listbox. In the Data binding, set the data field for the X axis to ProductName and the Y axis to UnitPrice.
    8. Select the Units in Stock data series and set its X-axis data field to ProductName and Y-axis to UnitsInStock.
    9. Select the Reorder Level data series and set its X-axis data field to ProductName and Y-axis data field to ReorderLevel.

      This should bind the chart properly with DataSet. And after this if you check ChartGroups>Group0>ChartData>SeriesList in the Properties Window, you see the proper data field name listed for Y Datafield.

    10. In the tree view, select Appearance>Header.
    11. In the Appearance [Header] tab click the Visible checkbox to enable the chart header.
    12. Select OK to close the Chart Properties.
    13. Run the application.

    You have successfully connected the chart to the data source and configured the chart's settings. To make our data more readable on the chart, in the next step we will add a listbox to filter the categories from the data.

    See Also