In This Topic
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:
- Open the C1ReportDesigner. For more information on how to access the C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.
- Create a new report or open an existing report. Once you have the report in the C1ReportDesigner, you can modify the report properties.
- Click the Design button to begin editing the report.
- In the Custom Fields group of the Insert tab, click the Chart Field button.
- Click in the Group Header section of your report and drag the field to resize the chart.
- 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.
Note: For the complete report, see report "11: Charts" in the CommonTasks.xml report definition file, which is available in the ComponentOne Samples folder.