Glossary Item Box

ActiveReports for .NET 2 Online Help Send feedback to Data Dynamics

2D Bar Chart

Bar charts are useful in comparing items across categories.

This walkthrough illustrates how to create a simple bar chart.

The walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the NorthWind database (Nwind.mdb).

When you have finished this walkthrough, you will have a report that looks similar to the following.

Creating a new Visual Studio project

To create a new Visual Studio project

  1. Open Visual Studio.
  2. Click on File > New > Project.

  3. Select the project type and click on Windows Application.
  4. Change the name of your project and click OK.

Adding an ActiveReport to a Visual Studio project

To add an ActiveReport to your project

  1. Open a new project in Visual Studio.
  2. Click on Project > Add New Item.
  3. Select ActiveReports file and rename the file rptBarChart.
  4. Click Open.

Adding a chart control to the report

To add a chart control to the report

  1. Resize the section in which you want to place the chart.
  2. Click the Charting icon in the ActiveReports toolbox and draw it onto the report.

Setting a data source for the chart

To connect the data source to a database

  1. With the chart control highlighted, click the Data Source... hyperlink below the Properties Window. (If the hyperlink is not visible, right-click an empty space in the Properties Window and click Commands to check that option.) This brings up the Chart DataSource dialog box.
  2. Click Build...
  3. Select "Microsoft Jet 4.0 OLE DB Provider" and click Next >>.
  4. Click on the ellipsis to browse to Nwind.mdb. Click Open once you have selected the file.
  5. Click OK to continue.
  6. In the Query field, type "SELECT ShipCountry, SUM(Freight) AS Expr1 FROM Orders GROUP BY ShipCountry."
  7. Click OK to return to the report design surface.

Setting the chart's properties

To set the chart's properties

  1. With the chart control highlighted, click the Customize... hyperlink below the Properties Window. This brings up the Chart Designer dialog box.
  2. In the ChartAreas section which displays by default, click to expand the Axes.
  3. Click Axis X, and on the Common tab in the pane to the right, type Country in the Title textbox and increase the font size to 12.
  4. Choose the Labels tab in the pane on the right, and check the Staggered Labels option to avoid overlapping labels.
  5. Click Axis Y on the left, and on the Common tab in the pane to the right, type Freight in the Title textbox and increase the font size to 12.
  6. Click the Titles button on the left side of the Chart Designer.
  7. Type Simple Bar Chart in the Caption textbox on the header title, and increase the font size to 14.
  8. Click the footer title in the upper left corner of the dialog, and delete it.
  9. Click the Series button on the left side of the Chart Designer, and click Series1 to select it.
  10. In the Data Binding box, set X (Name) to ShipCountry, and set Y to Expr1.
  11. Delete Series2 and Series3.
  12. Click the Legend button on the left side of the Chart Designer.
  13. Uncheck the Visible checkbox at the top of the Common tab to hide the legend.
  14. Click the Finish button to exit the Chart Designer.

Viewing the report

To view the report

  1. Add the ActiveReports viewer control to a Windows Form.
  2. Add the code needed to set the viewer document equal to the report document. See Using the ActiveReports WinForm Viewer for help.

 

 


Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.