ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Reports for WinForms Task-Based Help > Reporting Task-Based Help > Creating Report Fields > Creating Charts

Creating Charts

In the initial versions of C1Report, adding charts to reports required handling the StartSection event, generating the chart, and assigning the chart image to a field's Picture property. This is not hard to do, and continues to be the most flexible way to add dynamic images to reports.

However, this approach has two drawbacks:

      It requires you to write code outside the report definition, which means only your application will be capable of showing the report the way it is meant to be shown.

      It requires you to write code for generating the chart, which can be tedious.

The current C1Report supports custom report fields, including a chart field that is based on the C1Chart control.

To add a chart field to a Group Header section in your report, complete the following steps:

1.   Open the C1ReportDesigner. For more information on how to access the C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.

2.   Create a new report or open an existing report. Once you have the report in the C1ReportDesigner, you can modify the report properties.

3.   Click the Close Print Preview button to begin editing the report.

4.   In the Fields group of the Design tab, click the Add Chart Field button .

5.   Click in the Group Header section of your report and drag the field to resize the chart.

6.   From the Properties window, set the chart field's Chart.DataX and Chart.DataY properties to the values you want to display on the chart. You can show several series by setting the Chart.DataY property to a list of fields delimited by semicolons (for example, "UnitsInStock;ReorderLevel").

The chart data is automatically scoped to the current report group. For example, when rendering the "Beverages" section, only data for that category will be charted. You can customize the chart using many other properties such as Chart.ChartType, Chart.GridLines, Chart.Use3D, and Chart.Palette properties.

For more information on creating chart fields, see the Adding Chart Fields topic.

* Sample Report Available

For the complete report, see report "11: Charts" in the CommonTasks.xml report definition file, which is available for download from the CommonTasks sample on the ComponentOne HelpCentral Sample page.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.