You can create a report with a chart using the Data Dynamics Chart control.
This walkthrough illustrates how to create a report with a chart.
The walkthrough is split up into the following activities:
- Creating a Data Dynamics Report
- Connecting the report to a data source
- Adding a dataset
- Adding a chart control with data and grouping to the report
- Configuring the appearance of the chart
- Setting titles, labels, and scale on the axes
- Viewing the report
To complete the walkthrough, you must have access to the Reels sample database included with this installation.
When you are finished you will have a report that looks similar to the following.
Creating a Data Dynamics Report
To create a report in Visual Studio
- Create a new project in Visual Studio.
- From the Visual Studio Project menu, select Add New Item.
- In the Categories pane, select Data Dynamics Reports.
- In the Templates pane, select Report and name the report ProfitsByGenre.rdlx.
- Click Add in Visual Studio 2005.
Connecting the report to a data source
To connect the report to a data source
- If the Data Explorer is not in view, from the View menu, select Other Windows, then Data Dynamics Reports Data Explorer (at the bottom).
- Click the Add icon and select the Data Source... option.
- In the Report DataSource smart panel that appears, select the General page.
- Change the Name to Reels.
- Select the Shared Reference checkbox.

- Click the Browse button and select ReelsDataSource.rdsx, which is located in C:\My Documents\Data Dynamics\Reports\build number\Samples\Reels.

Note: In Windows Vista, the path is C:\User\your name\Documents\Data Dynamics\Reports\build number\Samples\Reels\. - Click the Accept button in the lower right corner to close the smart panel and see Reels appear in the Data Explorer.

Adding a dataset
To add a dataset
- Click the Add icon and select the Data Set... option.
- In the DataSet smart panel that appears, select the General page.
- Change the Name to ProfitsByGenre.
- On the Query page, paste the following SQL command into the Query text box:
SELECT Profit, SalesID, SaleDate, GenreName FROM SalesByGenre WHERE (SalesID < 1090) AND (GenreName = "Comedy" OR GenreName = "Drama" OR GenreName = "Adventure") ORDER BY SalesID;
- On the Fields page, add a new field by clicking in the empty cell below the fields listed in the Field Name column and giving it the name Month.
- Change the Type of the new field to Calculated Field.
- Set the Value of the new field to:
=Fields!SaleDate.Value.Month
This parses out the month from the date field. - Click the Validate icon to validate the query and to populate the Fields list.
- Click the Accept button in the lower right corner to close the smart panel and see ProfitsByGenre and the selected fields appear in the Data Explorer.

Adding a chart control with data and grouping to the report
To add a chart control to the report
- On the Layout tab of the report, click in the Body section of the report to select it.
- In the property grid, set the Size property to 6.5in, 4.5in to accommodate the chart.
- Drag a Chart control from the Toolbox onto the report.
- Select the chart type from the wizard "Select a Chart Type" - Column.

- Set the Location property to 0in, 0in and the Size property to 6.5in, 4.5in.
- Select the chart type from the wizard "Select a Chart Type" - Column.
- Click inside the chart to display the UI along the top, right, and bottom of the chart.
- From the ProfitsByGenre dataset, drag the Month field into the area below the chart labeled "Drop category fields here." This automatically binds the Month field to the X axis.
- To show user-friendly month labels on the X axis
- Right-click the month category group and select Edit to open the Category Groups smart panel.
- Enter the following expression under Label: =MonthName(Fields!Month.Value).
- Click the Accept button in the lower right corner to close the smart panel and accept the change.

- Drag the Profit field into the area above the chart labeled "Drop data fields here." This plots the profits to the Y axis of the chart.
- Drag the GenreName field into the area to the right of the chart labeled "Drop series fields here." This sets the series to be charted in the chart area.
- To show genre names in the legend
- Right-click the genre series group and select Edit to open the Series Groups smart panel.
- Select the following expression under Label: =Fields!GenreName.Value.
- Click the Accept button in the lower right corner to close the smart panel and accept the change.

![]() |
Note: The chart type used here is the simple column chart. For information on other chart types, see the Chart Types topic. |
Configuring the appearance of the chart
You can set chart properties in any number of ways with Data Dynamics Reports to make your charts more visually appealing. Here are some ideas to improve on the basic chart you just created.
To configure the appearance of the chart
- Right-click the chart and select Properties from the shortcut menu to open the Chart Report Item smart panel. (Use the back arrow at the top left to return to the main panel after each modification below.)
- To add a title to your chart
- From the Appearance page, select Title and enter Profits by Genre in the Chart title text box.
- Change the Size property to 14pt.
- To change the color of the bars in the chart
- From the Appearance page, select Chart Palette and drop down the list to select Light. (This is a good color choice because it differentiates between genres without highlighting one of them unintentionally.)
- From the Appearance page, select Chart Palette and drop down the list to select Light. (This is a good color choice because it differentiates between genres without highlighting one of them unintentionally.)
Setting titles, labels, and scale on the axes
To set titles, labels, and scale on the axes
- To add labels along the X Axis
- From the Chart Axes page, select X-Axis.
- Select Labels and select the Show x-axis labels check box.
- To remove the default title of the X Axis
- Click the X-Axis Title icon.

- Remove the default "Axis X" text under X-Axis title.
- Click the X-Axis Title icon.
- To remove the default title of the Y Axis
- Click the Y-Axis icon.

- Select the Title page.
- Remove the default "Axis Y" text under Y-Axis title.
- Click the Y-Axis icon.
- To add labels along the Y Axis
- Click the Y-Axis Labels icon.
- Select the Show y-axis labels check box.
- Set the Format code to currency formatting.
- Click the Y-Axis Labels icon.
- To set the currency labels to start at zero on the Y axis
- Click the Y-Axis Scale icon.
- Enter 0 (zero) for the Minimum.
- Click the Y-Axis Scale icon.
- Click the Accept button in the lower right corner to close the smart panel and apply your changes.
- From the File menu, select Save.
Viewing the report
Any report designed with Data Dynamics Reports can be opened in the included Data Dynamics Reports Viewer application or you can view it at design time.
To view the report at design time
- Click the Preview tab of the report designer.
To view the report at run time
- Add the ReportPreview control to your Visual Studio toolbox and drop it onto your Windows form.
- Set the Dock property of ReportPreview1 to Fill so that it will automatically resize if the form is resized at run time.
- Double-click the viewer to go to the Load event and use code like the following.
'Visual Basic.NET Dim rpt As New System.IO.FileInfo(Application.StartupPath & "..\\..\\ProfitsByGenre.rdlx") Me.ReportPreview1.OpenReport(rpt)
//C# System.IO.FileInfo rpt = new System.IO.FileInfo(Application.StartupPath + @"..\..\..\ProfitsByGenre.rdlx"); this.reportPreview1.OpenReport(rpt);
- Run the project.
Reference
Chart