Udostępnij za pośrednictwem


Adding Charts to a Report (Visual Studio Report Designer)

A chart is a graphical representation of the data in a report. Displaying data as a chart is visually appealing and makes it easy for users to see comparisons, patterns, and trends in the data. For example, instead of having to analyze several columns of data in a table or matrix report, you can see at a glance whether sales are decreasing or increasing over the past three quarters, or how year-to-date sales compare for the past three years. You can select from a variety of chart types and change a chart's style to include different colors, symbols, and three dimensional (3-D) effects.

Note

Microsoft licenses the chart control used in reports from Dundas Software. For more information about charting functionality available from Dundas Software, visit the company Web site at www.dundas.com.

How to Add, Delete, and Move a Chart

To work with a chart, open a client report definition (.rdlc) file in graphical design mode. To add a chart, drag the Chart report item from the Toolbox onto the report layout. Once the chart is on the report, you can select the chart type and other attributes by setting chart properties. You can size and position a chart by pointing to the shaded border and dragging it to a new location. You can add data by dragging fields to drop zones, or use the Edit Chart Value Dialog Box - Values Tab (Visual Studio Report Designer) tabbed dialog box to define or modify chart instance data. To delete a chart, right-click the shaded border of the chart, and then click Delete. Alternatively, press the DELETE key.

Modifying Chart Appearance

You can change the appearance of the plot and chart areas, the x- and y-axes, and legend in a chart. You can also apply a three-dimensional effect to the chart. The gradient plot area fill does not appear when the three-dimensional effect is applied. If you use a font size larger than 10 pt in the chart legend, some legend labels may be truncated. This may only be visible in larger font sizes.

To modify a chart, set properties in the Chart Properties Dialog Box - General Tab (Visual Studio Report Designer) tabbed dialog box. For more information about how to format a chart, see How to: Style a Chart Element (Visual Studio Report Designer).

Chart Data

Data for charts in report definition (.rdlc) files is organized into three axes: Values, Categories, and Series. Charts typically have two axes used to categorize and measure the data: a category (x) axis and a value (y) axis. The y-axis is usually the vertical axis and contains the data from the Value tab. The x-axis is usually the horizontal axis and contains the categories from the Category tab. The points on the resulting chart contain the data series from the Series axis. The Series axis is called the (z) axis. Pie and doughnut charts do not have axes. To display the axes areas, click the chart first.

Basic Chart data region

When you click on the chart, three drop zones appear, one for each area. You can drag fields from the Fields list onto each of these drop zones.

To add data to the chart layout, drag the fields from the Data Sources window onto a chart drop zone. To better understand how these different areas interact, it might be helpful to compare a chart layout to a matrix layout. The fields in a Value group are the equivalent of static rows or columns in a matrix layout. The fields in a Category group are the equivalent to dynamic column groups in a matrix layout. The fields in a Series group are the equivalent to dynamic rows in a matrix layout.

Values

The Value group is used to determine the size of the chart element for each category group. For example, a Values field determines the height of a column in a column chart or the size of a slice in a pie chart.

When you design a chart report, you need to add at least one field to the Value group. Value groups are static in charts. If you add only one field to the Value group and you do not add a field to the Series group, only a single chart element is displayed. If you add multiple fields to the Value group, a chart element is displayed for each value. If there are multiple fields in the Value group, the chart legend displays the name of each value.

Typically, data is grouped by category in a chart. If you are grouping your data based on category or series, you must use an aggregate expression for the value expressions in the chart. If you are not grouping data because you have only one field in the Category group, you do not need to use an aggregate field in the Value group.

Categories

Use categories to group data. Categories provide the labels for chart elements. For example, in a column chart, category labels are placed on the x-axis of the chart, one for each set of columns.

You can nest categories. When you define multiple categories, each category is nested within another category. For example, in a column chart that displays products by model, the first category group would be model, and the second category group would be product. The column chart would display groupings of products by model on the x-axis.

Series Groups

The Series group is used to add an additional dimension to the data in your report. For example, in a column chart that displays sales by product, you can add a field to the Series group to display sales by year for each product. You are not required to add a field to the Series group; it is optional when designing a chart.

If you do use a Series group, the name of the group is placed in the legend of the chart. Series groups are dynamic.

Choosing a Chart Type

You can choose from the following chart types: column, bar, line, pie, scatter, bubble, area, doughnut, and stock**.** The following table describes each type and provides a link to a topic that contains more information.

Topic Description

Column Chart Type (Visual Studio Report Designer)

Describes column charts. Column charts display data as sets of vertical columns. Includes information about hybrid column/line charts.

Bar Chart Type (Visual Studio Report Designer)

Describes bar charts. Bar charts display data as sets of horizontal bars.

Line Chart Type (Visual Studio Report Designer)

Describes line charts. Line charts display data as a set of points connected by a line.

Pie Chart Type (Visual Studio Report Designer)

Describes pie charts Pie charts display data as percentages of the whole.

XY (Scatter) Chart Type (Visual Studio Report Designer)

Describes XY (scatter) charts. XY charts display data as a set of points in space.

Bubble Chart Type (Visual Studio Report Designer)

Describes bubble charts. Bubble charts display set of symbols whose position and size are based on the data in the chart.

Area Chart Type (Visual Studio Report Designer)

Describes area charts. Area charts display data as a set of points connected by a line, with a filled-in area below the line.

Doughnut Chart Type (Visual Studio Report Designer)

Describes doughnut charts. Doughnut charts display data as percentages of the whole.

Stock Chart Type (Visual Studio Report Designer)

Describes stock charts. Stock charts display data as a set of lines with markers for high, low, close, and open values.

See Also

Tasks

How to: Style a Chart Element (Visual Studio Report Designer)
How to: Position Labels in a Pie Chart (Visual Studio Report Designer)

Concepts

Defining a Report Layout (Visual Studio Report Designer)
Creating Client Report Definition (.rdlc) Files