ActiveReports for .NET 3 Online Help Request technical support
2D Bar Chart
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Basic > Chart Walkthroughs > 2D Bar Chart

Glossary Item Box

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.
A copy is located at C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data\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. From the File menu, select 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. From the Project menu, select Add New Item.
  3. Select ActiveReports 3.0 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 ChartControl icon in the ActiveReports toolbox and draw it onto the report.
Note: If the chart wizard appears, click Cancel. If you do not want it to appear each time you add a chart, deselect the Auto Run Wizard checkbox.

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 verb below the Properties Window to open the Chart DataSource dialog box. (If the verb is not visible, right-click an empty space in the Properties Window and click Commands to check that option.) 
  2. Click Build.
  3. Select "Microsoft Jet 4.0 OLE DB Provider" and click Next.
  4. Click the ellipsis to browse to the Northwind database. 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 verb below the Properties Window to open the Chart Designer dialog box.
    If you do not see the verbs in Visual Studio 2005, right-click the Properties Window and select Commands
  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 select 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. Deselect 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 Windows Form Viewer for help.
You can quickly view your report at design time by clicking the Preview tab at the bottom of the designer.

See Also

©2009. All Rights Reserved.