Charts and Graphs

book list add book to my bookshelf create a bookmark purchase this book online

mastering crystal reports 9
Chapter 12 - Analyzing Data Visually
Mastering Crystal Reports 9
by Cate McCoy and Gord Maric
Sybex 2003

Crystal Reports contains a completely integrated graphic module that can quickly chart the data in your report. There are 14 standard chart types like bar, line, and pie as well as variations within each chart type like side-by-side bar chart, stacked bar chart, and percent bar chart, which, provide a wide variety of graphing capability within a compact interface dialog.

The presence of groups and summarized values in a report is the starting point for using charting, mapping, and cross-tabs. Figure 12.1 shows the first page of a report that’s suitable for charting, which answers the business question with data and summarization.

Business Question: Create a report that shows resort unit purchase prices by resort and country and is split into regions of North America, Caribbean, Europe, and Others.

click to expand
Figure 12.1. First page of report

Figure 12.2 shows the same report with a chart of the report data placed in the Report Header. Notice that the graphic very quickly lends itself to answering the business question without having to scan all of the pages of the report and add up the numbers. Charts can be used in combination with detail data to completely provide the information and as well as the ability to compare and contrast summary values.

click to expand
Figure 12.2. A bar chart in a report

Creating a Chart or Graph

The Chart Expert in Crystal is used to create both charts and graphs; a graph is considered to be a type of chart. You can open the Chart Expert from the menu by choosing Insert > Chart.

Once open, the Chart Expert displays tabs for configuring the key information for a chart. Figure 12.3 shows the Chart Expert and five tabs: Type, Data, Axes, Options, and Text. Not all chart types use all five tabs. In addition, the options available on each tab are based on the type of chart chosen on the Type tab. The Axes and Options tabs are suppressed when the Automatically Set Chart Options check box is enabled.

click to expand
Figure 12.3. Chart Expert

Choosing a Chart Type

Use the Type tab to choose the chart visual that will best represent the story your data is trying to tell. Each chart type represents the data a bit differently. Pie charts are good for showing data values as they relate to 100 percent, while bar charts can easily show data that doesn’t reach 100 percent. Use a chart that gets your point across. Configuration includes choosing the type of chart to create and, within that type, the visual effects particular to that chart. Crystal is smart enough to know whether the data in your report supports a particular type of chart. For instance, if you have no date/time values in your report, the Gantt chart option is unavailable.

Each chart type has a number of variations as to how it can be presented. Use the buttons on the right side of the dialog (Figure 12.3) to choose a chart variation.

Bar Solid rectangular bars and stacked rectangular bars display in side-by-side mode to display individual data items, groups, and subgroups. Using this type of chart, you can visually compare one set of values to another based on the size of the rectangles and their component rectangles and present percentage information.

Line Individual data points are connected inside an X/Y coordinate system to form lines representing data trends.

Area Within an X/Y coordinate system, lines are drawn to represent data points, and the area beneath the line is shaded to represent the volume of data for the area being covered. This chart type can show trends over time.

Pie Pie charts are most useful when 100 percent of the data (values, groups, or subgroups) is to be charted and each of the contributing parts is significant enough to display in the pie. For instance, a pie chart that shows data with a 30–30–40 percent split creates a nice visual, while a pie chart showing data with a 2–2–2–4–10–10–70 percent split might not be as helpful to the user visually. There is no time component to a pie chart, so no X/Y coordinate system is used.

Doughnut A doughnut chart does exactly what a pie chart does; however, it has the additional capability of showing a data value in the center hole. For example, the total sales for the year can be included as a text value in the center of the doughnut, while the doughnut slices each show a relative percentage for each resort’s sales.

3D Riser 3D riser charts are three-dimensional blocks, pyramids, cylinders, and rectangles. The data is represented in three dimensions instead of the normal two for X/Y coordinate systems. Time is usually one of the three dimensions. This type of chart is useful with grouped data and spreadsheet data.

3D Surface Three dimensions are used to show trends over time in a surface analysis chart. The topology depicts the lows and the highs in data values over time.

XY Scatter Using an X/Y coordinate system for bivariate analysis, XY scatter charts plot data points representing discrete or grouped data values for two variables. The data is scattered across the plane, showing patterns and density of data.

Radar Data is presented in a grid of concentric circles, showing patterns of data.

Bubble Using an X/Y coordinate system for trivariate analysis, bubble charts plot data points representing discrete or grouped data values for three variables. The data is scattered across the plane, showing patterns and density of data.

Stock Floating bar charts show limit values together with plotted data value points. This type of chart is useful for showing trends over time within limits, such as minimums and maximums.

Numeric Axis The numeric axis chart changes values for each data value plotted on the X-axis. It combines a visual representation of the data with a numeric data representation. Numeric axis charts can be bar charts, line charts, or area charts.

Gauge Showing a gauge that goes from a low value to a high value, left to right, the gauge chart presents a dial that incorporates colors to show values in acceptable or dangerous ranges. Single categories of data are good candidates for this type of chart as it shows values as they relate to the 100 percent mark. This chart type is new in Crystal Reports 9.

Gantt Gantt charts represent time-based milestones as horizontal bar charts in an X/Y coordinate system. This type of chart is popular for project management and forecasting. Date fields are required in the data in order to create Gantt charts. This chart type is new in Crystal Reports 9.

Configuring Data Options

Use the Data tab to configure options specific to the data points being plotted or charted. There are three areas on this tab: Placement, Layout, and Data. Within the Placement area, you choose where the chart will be placed in the report and the frequency of occurrence. Choosing Once Per Report means it will be placed in the Report Header or Footer; choose the Header or Footer radio button to indicate where to place the chart. Additional choices in the drop-down box map directly to the presence of groups in the report. In Figure 12.4, the phrase “For each” represents the groups that exist in the report.

click to expand
Figure 12.4. Data options

After choosing the placement option, you must next decide what kind of chart layout best matches your data. There are four layouts: Advanced, Group, Cross-Tab, and OLAP. If a layout button is available, then the appropriate type of data is present in the report, so if the report does not contain groups, cross-tabs, or OLAP data, these buttons are unavailable. If a group is available, the Group button is the default; otherwise, the Advanced option is preset. Charting group data is the simplest method to create a chart because the on-change events in the Data area within this tab correspond to the groups. It is reasonable to assume that if the report segments the data into groups, then the charts in the report will display information relative to these groups.

The Advanced option gives you the opportunity to work with detail data and any field contained in the report or the data source underlying the report. Figure 12.5 shows the Data tab with the Advanced option selected. In this chart, the average purchase price of a resort is being graphed relative to the country and state or province in which it is located.

click to expand
Figure 12.5. Advanced layout option

You can set the frequency of the chart in the report using the drop-down box in the Data area of the dialog, which has three choices:

  • On Change Of

  • For Each Record

  • For All Records

The setting you choose will determine the frequency or periodicity of the data being graphed. To help decide between the options, ask yourself the question, “What kind of segmentation do I want to see in the data?” When you choose On Change Of, the values in the field of your choice will be summarized each time the value changes. For a field like Country in the VistaNations data, this means that a data point will be created for each country that has a resort, and the X-axis will show the set of countries found in the data. Figure 12.6 illustrates the X-axis and the Y-axis.

click to expand
Figure 12.6. X-axis and Y-axis

The On Change Of drop-down list is directly related to the field you place in the box just below it; you add a value by selecting it from the Available Fields list on the left and using the arrow key in the middle to copy it over to the list on the right. You can add multiple fields to this area, creating groups and subgroups on the X-axis. Selecting (highlighting) one of the fields in this area will enable the Order and TopN buttons; otherwise, they are disabled. The Order button lets you change the chart sort order using the dialog shown in Figure 12.7. Here, you can resort and regroup the data in the report, and if the chosen field was a specified order group, the options for adding members, deleting members, and managing others in the custom group are available as well. The TopN button lets you add a TopN filter to the data at this point.


Figure 12.7. Chart Sort Order

Choosing the option For Each Record or For All Records in the frequency drop-down box shown in Figure 12.5 will create a chart directly based on the detail data in the report. There is no need to select a field for these two frequencies because all data in the report is considered and summarized for chart purposes.

Tip 

Selecting the For Each Record or All Records option clears out the value in the field area below the drop-down box.

In the Show Value(s) area at the bottom right of the Data tab shown in Figure 12.5, you choose the summarized data value to be plotted in the chart. The values for the Y-axis are derived from the plotted data. For instance, if you choose to summarize the average purchase price for a resort, the lowest purchase price will be the value shown at the bottom of the Y-axis and the highest purchase price will be the value shown at the top of the Y-axis. The data points are then graphed against these low and high values to show the data distribution. The Summarized field that is added to this part of the Data tab determines what the bar, pie, or scatter chart actually plots as data values. Clicking the Set Summary Operation button opens the Edit Summary dialog, shown in Figure 12.8, allowing you to change the statistical operation being performed to any valid Crystal summary. In addition, you can enable the option to show the data values in the chart as percentages in place of the summary value.


Figure 12.8. Edit Summary

Enabling the Don’t Summarize check box option shown in Figure 12.5 will prevent Crystal from summarizing the value and will instead present the raw data points in the chart.

Modifying Axes Information

Using the Axes tab, you can configure options to control how the label data on the axes appears. You can set minimum and maximum values and enable automatic segmenting of the axes. An option exists to AutoScale the labels so that if there are too many labels to display, fewer labels will be placed on the chart, enabling the remaining ones to be clearly displayed. The Axes option appears only for charts that use an X-, Y-, or Z-axis; pie charts, doughnut charts, and Gantt charts do not use axes. Crystal can use default values for all of these settings if you enable the Automatically Set Chart Options check box on the Type tab (shown previously in Figure 12.3).

Note 

If the Automatically Set Chart Options check box on the Type tab is enabled, the Axes tab will not be visible.

Controlling Additional Options

The Options tab of the Chart Expert, shown in Figure 12.9, controls the settings for a chart’s color, the labeling format used, background color and behavior, and data legend configuration. You can change the colors a chart shows or display it in black and white to save color ink on those printers! The Marker Size field refers to how large the shapes representing data in the chart will appear. When working with pie data (not shown in Figure 12.9), additional options exist to detach the pie slices, set the pie size, and show data values as percentages or actual numbers. Crystal can use default values for all of the settings on the Options tab if you check the

Automatically Set Chart Options check box on the Type tab (see Figure 12.3).

click to expand
Figure 12.9. Setting chart options

Note 

If the Automatically Set Chart Options check box on the Type tab is enabled, the Options tab will not be visible.

Customizing a Chart

Once you’ve created a chart and placed it in a report, you can go back and revise it as well as add more formatting to it. When a chart is selected, the Chart menu becomes visible on the main menu, or you can right-click the chart to open the submenu specific to charts. The three main configuration options for modifying a chart available from the menu are Chart Expert, Chart Options, and Format Chart.

Choosing the Chart Expert reopens the dialog that was used to originally create the chart. You can change all or any of the original settings. Usually you’ll build a quick chart, see what it looks like, and then reopen the Chart Expert to fine-tune the data distribution choices and grouping choices based on how well your initial attempt fit your needs. Since building charts can be more of an art than a science, an incremental approach to the process is very helpful. Make a change, and then preview the result to see what happened.

Using Chart Options

A new feature in Crystal Reports 9 is the ability to modify the chart using an “in-place” approach to formatting. The changes you make using the Chart Options menu item are immediately applied to the underlying report, changing it in-place with no need to delete it and re-create the chart. A chart consists of many internal items; each item can be selected and edited in place. Figure 12.10 shows the submenu from the Chart Options menu with all items active; depending on the type of object selected, a menu option may be grayed out and unavailable.


Figure 12.10. Chart menu options

Note 

Custom chart options are not available if the typical install of Crystal Reports was performed; the custom install allows the addition of Custom Charting functionality.

Template

Chart templates are a way to apply user-defined styles or built-in styles to a chart. In the Gallery of chart templates, shown in Figure 12.11, you can choose from a standard chart type and then change the layout, size, and other settings using options specific to the chart type.

click to expand
Figure 12.11. Chart templates

The Custom tab behind the Gallery tab provides access to several sets of custom chart templates, including those that are user-defined. For user-defined chart templates, the idea is that you find a chart type that you like, customize it, and save the result as a template that can be reused. Any chart you build can be saved as a chart template file by choosing Chart > Save As Template. User-defined chart templates are saved with the filename of your choice and a .3TF extension. The 3 is there as an indirect reference to the third-party company that created all the built-in chart templates, Three D Graphics, Inc. Prebuilt chart templates are stored beneath the Crystal Decisions installation directory in the C:\Program Files\Common Files\Crystal Decisions\2.0\ChartSupport\Templates directory, while user-defined chart templates can be found in the C:\Program Files\Common Files\Crystal Decisions\2.0\ChartSupport\Templates\User Defined directory. Figure 12.12 shows the set of custom charts available. You can see thumbnail sketches of the variations of a chart category by selecting its name. If you have stored any charts in the User Defined subdirectory for custom charts, they too will have thumbnails.

click to expand
Figure 12.12. Custom chart templates

The Help button in the chart template area is especially useful to a report designer as it is an entire help resource dedicated to working with the custom charts provided by the Three D Graphics folks.

Note 

Chart templates are available only if you installed the complete version of Crystal Reports or chose the Custom Charting option during a custom installation.

General

Choosing the General option from the Chart Options menu opens a dialog that is also labeled Chart Options; this can be a little confusing. Here, six tabs of information let you customize a chart, as shown in Figure 12.13: General, Layout, Data Labels, Numbers, Look, and Display Status. You can set general formatting and layout options for a chart in this dialog. The options available change based on the type of chart chosen. For instance, on the graphics side of the story, pie charts can be tilted, rotated, exploded (really!), compared to other pies, have their size set proportional to their data, or turned into doughnut charts. On the value side of the pie chart, data labels can be changed or suppressed, percents shown as values, and legends positioned or suppressed. All in all, a great bit of fun awaits when you start playing with the General options and discovering the granular control you have over your charts.

click to expand
Figure 12.13. General chart commands

Titles

A chart is labeled with several descriptive titles. Crystal generates default titles automatically based on the groups and data values chosen to be part of the chart. Figure 12.14 shows the Titles configuration dialog.

click to expand
Figure 12.14. Customizing chart titles

You can override the values by any of the titles by typing a new value; the default position of the title relative to the chart is noted here:

Title The Title value appears above the chart.

Subtitle The Subtitle appears below the Title but above the chart in a smaller font and lighter shade than the Title.

Footnote The Footnote appears at the bottom of a chart in the lower-right corner.

Group Title The Group Title appears below the chart along the X-axis.

Data Title The Data Title appears on the left side of a chart on the Y-axis and rotated 90 degrees.

Grid

When charts with X/Y or X/Y/Z axes are selected (bar charts, scatter charts, etc.), you can choose the Grid menu item to finesse formatting options on the chart axes, grid lines, and scales. You can set such options as the size and location of labels in relation to the axes. Figure 12.15 shows the Numeric Axis Grids & Scales dialog box with its assorted tabs. Notice that there are tabs located along both the side and the top.

The majority of charts are arranged within two dimensions. Two of the possible tabs along the left side deal with detail data versus group data, or the X and Y coordinate planes. The tabs along the top (General, Scales, Labels, Numbers, and Grids) may or may not apply to the detail or group data. For instance, in Figure 12.15, the Data Axis tab is chosen along the left. Along the top, the General, Labels, Numbers, and Grids tab are not grayed out and therefore have settings that can be changed. Not all of the top tabs apply to the tabs at the left; for instance, when the Group Axis tab is active, the Numbers tab is grayed out since detail data numbers do not appear (numbers are not used as group values on a chart axis).

click to expand
Figure 12.15. Grid customizations

For three-dimensional charts, like 3D risers, a third tab appears along the left side of the dialog showing the Series dimension, or Z coordinate plane. The General, Labels, and Grids tabs are available for customizing this information dimension.

Selected Item

In this release of Crystal Reports, each component of a chart is an individual item that, when viewed with the set of all items, forms the chart. Individual items include titles, background graphic components, axis labels, and data object representations. When selected, they can be repositioned and resized within the chart as part of the in-place graphics editing capabilities of Crystal. Choosing the Selected Items command opens the Formatting dialog shown in Figure 12.16. The tabs available in this formatting window are dependent on the type of item (object) selected. Here you can set fonts, lines, and fill colors for each item. This granular level of control gives you complete flexibility in the chart’s visual presentation.

click to expand
Figure 12.16. Changing chart item fonts

Viewing Angle

You can change the viewing angle of a chart to highlight different aspects of the data. Thumbnail pictures of standard viewing angles appear on the left side of the dialog shown in Figure 12.17; simply click a thumbnail to select that viewing angle. Alternatively, you can maneuver the chart three-dimensionally using the Rotate, Pan, Walls, and Move tabs found at the bottom-right corner of the dialog. This part of the screen is made visible when you click the Advanced Options button on the starting screen; clicking the Presets Only button on this dialog returns you to the starting screen.

click to expand
Figure 12.17. Changing a chart’s viewing angle

Series

The Series menu option is available only when three-dimensional charts are being used and when a series item is selected. Series represents the third dimension, or Z coordinate plane, in a three-dimensional graph. Figure 12.18 shows that you can manipulate general items and data labels for the selected series item.

click to expand
Figure 12.18. Z coordinate series settings

Formatting a Chart

The Format Editor is the familiar control area used with all Crystal objects to set basic options. To open the Format Editor for the chart, select the chart on the page and then choose Format > Format Chart, or right-click the selected chart to directly choose Format Chart from the submenu. The Format Editor contains tabs that allow you to format the current object of focus (the chart) for page and layout issues. As with other objects in Crystal, you can use the universal Format Editor to format the chart with options such as conditionally suppressing based on a formula, drawing a border around the chart, and adding a hyperlink to another destination. Every object in Crystal is also given a unique object name, like Graph1, so that it can be manipulated programmatically through languages such as Java and the languages used with the .NET platform; the programmatic name for the object is set using the Format Editor.

Use of content on this site is expressly subject to the restrictions set forth in the Membership Agreement
 
Conello © 2000-2003     Feedback


Mastering Crystal Reports 9
Mastering Crystal Reports 9
ISBN: 0782141730
EAN: 2147483647
Year: 2005
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net