Viewing: Working with the Ad Hoc Editor > Chart Types

Working with Charts

The following sections explain how to populate, edit, and format your View for a chart-type report.

Charts are graphical representations of data. Many tasks related to working with charts are identical (or very similar) to those for table reports. For any tasks not discussed in this section, see the information in section Working with Tables.

Chart Types

Charts have different layout and format options from tables and crosstabs.

There are a number of chart types to choose from to best represent your information. These types are broken into two categories:

   Summarized charts, which show data grouped and summarized.

   Unsummarized charts, which show each data point individually, and don’t support grouping. Unsummarized charts can only be run or saved if the fields selected for the X and Y axes are appropriate.

The Ad Hoc Editor can create both summarized and unsummarized charts.

Summarized chart types include:

   Bar, which compares values displayed as bars.

   Pie, which compares values displayed as slices of a circular graph.

   Line, which compares values displayed as points connected by lines.

   Area, which compares values displayed as shaded areas.

Unsummarized chart types include:

   Scatter, which compares values expressed as pairs that determine the position of a point on the chart. For scatter charts, both fields must be numeric.

 

A scatter chart uses Cartesian coordinates to display values as points whose locations are determined by two variables you select. One variable determines the horizontal position and the other determines the vertical position. The chart plots paired values against one another.

   Time Series, which compares values based on times or dates associated with the data. Use a date field as the group. For time series charts, one field must be a date or date/time, and the other must be numeric.

 

Time series charts plot the data against the passage of time. They can help you understand the nature and underlying context of the data, identify trends, or forecast future results. In a time series chart, the horizontal axis must represent a date or time field, such as Purchase Date. If you add a field to the horizontal axis that has a datatype other than a date/time, the Ad Hoc Editor renders the chart as best it can, but the result is likely to be meaningless.

Because these charts are unsummarized, the Change Summary Function option is not available for them.

By default, the Ad Hoc Editor creates a bar chart. You can select a different type of chart at any time.

To select a new chart type:

1.     In the Ad Hoc View panel, right-click the chart.

2.     Select Change Chart Type.

3.     Select the type of chart you want to apply to your report.

You can right-click the chart to open a context menu that provides these formatting categories:

   Change Chart Type

   Display Options

   Legends and Labels

   Remove Group

   Change Summary Function

   Change Data Format

   Add/Remove Measure

The options available in the Display Options category vary depending on the type of chart you are working with. The following table describes the options for each chart type:

 

Table 0‑1 Ad Hoc Display Options

Type

Context Menu Options

All Chart Types

w Remove Gradient or Apply Gradient. Whether the background color should be graded or solid. When the gradient is removed, the background is filled with a solid color.
w Remove Background or Fill Background. Whether the background should be filled.

Note that the gradient doesn’t appear when you run the report.

Bar

w Flat Bars or 3D Bars. Whether to use a flat, two dimensional appearance, or a three dimensional (3D) appearance.
w Stacked or Simple Series. Whether multiple measures of each group are depicted as individual bars or as portions of a single bar. Note that a series chart displays multiple measures for each group value.
w Horizontal Bars or Vertical Bars. Whether the bars are parallel to the width or height of the chart.

Pie Chart

When creating a pie chart, you can indicate whether to use a two-dimensional Flat Pie, or the default three-dimensional 3D Pie.

Line Chart

When creating a line chart, you can indicate whether to display markers at each data point and lines that join them. Select Hide Lines or Show Lines, and Hide Points or Show Points, to remove or display those indicators from the chart.

Area Chart

When creating an area chart, you can indicate whether the groups should be displayed as transparent overlays or as solid areas. Select Stacked Series to display the groups as solid areas arranged vertically, one on top of another; select Simple Series to display groups as transparent overlays.

As compared to line charts, area charts emphasize quantities rather than trends.

Scatter

When creating a scatter chart, you can indicate whether to display markers at each data point and lines that join them. Select Hide Lines or Show Lines, and Hide Points or Show Points, to remove or display those indicators from the chart.

Time Series

When creating a time series chart, you can indicate whether to display markers at each data point and lines that join them. Select Hide Lines or Show Lines, and Hide Points or Show Points, to remove or display those indicators from the chart.

Using Fields and Measures in Charts

Data is added to your chart as a group or as a measure. All available fields are listed in the Data Selection panel, as either standard fields or measures.

   Standard fields can be added to the chart as a measure or a group.

   Measures contain summarized values; therefore, they cannot be added to the chart as a group.

Before any fields are added to the chart, the Ad Hoc Editor displays a placeholder with the legend displaying a single entry: No Data. As you add groups and measures, the placeholder changes to reflect the data in the chart. For example, when you add a group to a pie chart, the pie displays the correct number of pie slices; when you add a measure to a bar chart, the Y-axis units and values show the range of values in the measure you selected.

Chart Measures

Chart measures are typically numeric fields that determine the length of bars, size of pie slices, location of points (in line charts), and height of areas.

 

The Ad Hoc Editor displays only the first measure when you change to a pie chart because pie charts can show only a single measure. Any additional measures are displayed when you change back to a bar or other chart type.

To add a field to a chart as a measure:

1.     In the Data Selection panel, click to select the field or measure you want to add to the chart as a measure. Use Ctrl-click to select multiple items.

2.     Drag the selected item into the Measures box in the Layout Band.

The field is added to the chart.

To remove a measure field from a chart:

   In the Layout Band, click the x next to the field or measure’s name.

If the chart displays multiple measures, the context menu lists them under the Measures menu item. The measures are listed in the order they appear within the groups. On the chart context menu, click Measures  [Measure Name]  Remove Measure (where [Measure Name] is the name of the measure you want to remove).

 

The Measures menu also allows you to change the summary function and data format. It is available from the chart context menu as well as from the legend.

Chart Groups

Similar to the table's grouping option (described in section Groups), a chart’s group field determines how data is categorized. For example, in a bar chart, the category field determines how the bars are grouped; in a pie chart it determines what each slice represents.

 

Measures cannot be used as groups.

Time series and scatter charts don't support grouping; instead, each data point is mapped individually. The data aren’t summarized.

To add a field to a chart as a group:

1.     In the Data Selection panel, click to select the field you want to add to the chart as a group. Use Ctrl-click to select multiple items.

2.     Drag the selected item into the Groups box in the Layout Band.

The field is added to the chart.

3.     To replace a group already added to the chart, right-click a new field and select Replace Group, or simply drag the new field into the Groups box in the Layout Band.

To remove a group field from a chart:

   In the Layout Band, click the x next to the field’s name.

Legends and Labels

You can rename the measures displayed in the chart by right-clicking the measure’s label in the legend and selecting Edit Legend Label from the menu that appears. The text you enter replaces the field’s name.

If you change the measure’s summary function, the label updates to reflect the change. If you change the summary function back, the last name entered for that measure with that summary function appears.

You can hide legends and labels to give the chart more space, or you can show them to make the chart easier to understand.

To show or hide legends and labels:

1.     Right-click the chart and select Legends and Labels.

2.     Specify whether to hide or show the legend, the group title (which identifies the name of the group field), or measure titles (which identifies the measures).

When working with a chart that displays two measures with very different ranges of values, the chart may be difficult to read or understand. To make the ranges of values more similar, create a custom field that multiplies or divides one of the measures. Consider the case where you are comparing the number of items sold (values ranging from 0-50) and the total sales revenue for each product (values ranging from 0-50,000), you could create a custom field that divided the revenue measure by 1000. Adding this measure in place of the actual revenue measure yields a chart in which the two measures are depicted in closer scale. The new chart is both easier to read and more appealing. Jaspersoft recommends that you note such changes in the legend label or title.

To add a field in a specific position in a chart:

1.     Click to select the field you want to add to the chart.

2.     Drag and drop the field onto the chart legend, in the desired location. The new measure appears in the correct location in the chart

Resizing a Chart

By default, the page is set to Actual Size, which resizes the page to fit the chart’s dimensions.

You can increase a chart’s size to improve its legibility or decrease its size if it’s intended for use in a Jaspersoft dashboard or JSR-168 compliant portal, such as Liferay. When you place the cursor over the right-hand or bottom edge of the chart, the resize arrow appears; click and drag the edge of the chart to increase or decrease its size.

For more information about portal integration, refer to the JasperReports Server Administrator Guide.