Changes

Summarize iReport Template Data

23,759 bytes added, 19:31, 23 October 2012
no edit summary
<li>From the Library pane, click the name of the variable that you created for the average.</li>
<li>Drag the variable to the summary section of the report.</li>
</ol>
 
==Charts==
 
Charts provide a visual representation of the report data. Before you add a chart to your report, you should ensure that your report contains the following:
*At least one grouping. The report groupings are used by iReport to determine what fields may be plotted.
*At least one variable that contains a calculation. This calculation may be a count, total, or other custom calculation. These calculated variables define the size of the chart segment.
 
===Pie Chart===
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || The sample report ''Pie Chart Sample.jrxm l''in the <''iReport Installation Directory''>\iReports_IMSMA\IMSMA reports directory provides an example of a report that includes a pie chart.
|}
 
To add a pie chart to the report:
<ol>
<li>Create a report which groups the results by the attribute on which you would like to base your chart.</li>
<li>After creating the report, you should add a footer for the attribute on which the results will be grouped. This footer will be used to display the total for the group that will subsequently be used in the pie chart. To add a group footer:</li>
<ol type="a">
<li>From the '''View''' menu, select '''Bands'''.</li>
:The <FileName> bands… window displays.
<li>Select <''GroupAttribute''>Footer from the left pane where ''GroupAttribute'' is the name of the attribute on which the results will be grouped. For example, if you are creating a report on hazards and group the results by the priority, the name of the band would be ''priorityFooter''.</li>
<li>In the right pane, enter a numeric value in the Band Height field. You may adjust the height of the summary.</li>
<li>Click the '''Apply''' button.</li>
</ol>
<li>Add a summary section to the report.</li>
<li>Click the [[Image:iRepBarChart.png]] icon.</li>
<li>In the summary section of the report, hold down the mouse button and drag the cursor to form the rectangle which will contain the chart.</li>
:A window of the various chart options displays.
<li>Select one of the pie chart options.</li>
</ol>
 
[[Image:iRep26.png|center|500px|''Figure 26. Pie chart options'']]
<div align="center">
''Figure 26. Pie chart options''
</div>
 
<ol start="7">
<li>Click the '''OK''' button.</li>
<li>Right-click anywhere on the chart.</li>
<li>Select the '''Chart Properties''' option.</li>
<li>From the Chart Properties window, select the Chart Data tab.</li>
<li>From the Chart Data tab, select the Details tab.</li>
<li>The Section Value tab should be selected by default. If it is not, select it.</li>
<li>The '''Key Expression''' defines the various slices of the pie chart. This will typically be each unique value for an attribute. For example, if the chart were to contain the total area size of hazards with a particular priority, the Key Expression would return the unique values for priority (e.g., Low, Medium, or High). To enter the key expression value:</li>
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Key Expression field.</li>
:The Expression editor window displays.
<li>From the bottom pane, double-click the name of the attribute that contains the data that you would like to include in the chart.</li>
:The expression to represent the attribute displays in the top pane.
<li>In order to account for null values, you will need to modify the expression so that null values are grouped into their own group. The expression should be modified to include the bolded text below. You should replace attribute with the name of the attribute that you selected in step b above.</li>
:$F{''attribute''} '''!= null ? $F{''attribute''} : "Unknown"'''
<li>Click the '''Apply''' button.</li>
</ol>
<li>The '''Value Expression''' field contains the expression that returns the numeric value for the key. For example, it may be the total hazard size of high priority hazards.</li>
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Value Expression field.</li>
:The Expression editor window displays.
<li>From the Objects and expressions tab, select '''Variables''' from the left pane.</li>
<li>From the middle pane at the bottom of the Expression editor window, double-click the name of the variable that was created to store the total.</li>
<li>Click the '''Apply''' button.</li>
</ol>
<li>The '''Label Expression''' field contains the expression that is used to determine the label for the segment of the pie chart. Because this expression will most likely be the same as the one used in the '''Key Expression''', you can copy the expression from the Key Expression field and paste it into the '''Label Expression''' field.</li>
<li>[[:Image:iRep27.png|Figure 27]] is an example of the Chart Properties window for a report that contains a pie chart which graphs the total area size of hazards based on their priority.</li>
 
</ol>
 
[[Image:iRep27.png|center|500px|''Figure 27. Chart Properties'']]
<div align="center">
''Figure 27. Chart Properties''
</div>
 
<ol start="17">
<li>Click the '''Close''' button</li>
:The Chart Properties window closes.
<li>Save the report by either clicking the icon, or by selecting the '''Save''' option from the '''File''' menu.</li>
</ol>
 
Below ([[:Image:iRep28.png|Figure 28]]) is an example of a report template that totals the area size of hazards by priority.
 
[[Image:iRep28.png|center|500px|''Figure 28. Sample report template with pie chart'']]
<div align="center">
''Figure 28. Sample report template with pie chart''
</div>
 
The resulting report pages are shown in [[:Image:iRep29.png|Figure 29]].
[[Image:iRep29.png|center|500px|''Figure 29. Sample report with pie chart'']]
<div align="center">
''Figure 29. Sample report with pie chart''
</div>
 
===Bar Charts===
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || The sample report ''Bar Chart Sample.jrxm l''in the <iReport Installation Directory>\iReports_IMSMA\IMSMA reports directory provides an example of a report that includes a bar chart.
|}
 
To add a bar chart to the report:
<ol>
<li>Create a report which groups the results by the attribute on which you would like to base your chart.</li>
<li>After creating the report, you should add a footer for the attribute on which the results will be grouped. This footer will be used to display the total for the group that will subsequently be used in the pie chart. To add a group footer:</li>
<ol type="a">
<li>From the '''View''' menu, select '''Bands'''.</li>
:The <FileName> bands… window displays.
<li>Select <'''GroupAttribute'''>Footer from the left pane where ''GroupAttribute'' is the name of the attribute on which the results will be grouped. For example, if you are creating a report on hazards and group the results by the priority, the name of the band would be ''priorityFooter''.</li>
<li>In the right pane, enter a numeric value in the Band Height field. You may adjust the height of the summary</li>
<li>Click the '''Apply''' button.</li>
</ol>
<li>Add a summary section to the report.</li>
<li>Click the [[Image:iRepBarChart.png]] icon.</li>
<li>In the summary section of the report, hold down the mouse button and drag the cursor to form the rectangle which will contain the chart.</li>
:A window of the various chart options displays.
<li>Select one of the bar chart options.</li>
<li>Click the '''OK''' button.</li>
<li>Right-click anywhere on the chart.</li>
<li>Select the '''Chart Properties''' option.</li>
<li>From the Chart Properties window, select the Chart Data tab.</li>
<li>From the Chart Data tab, select the Details tab.</li>
<li>Click the '''Add''' button.</li>
:The Chart Properties window displays. By default, the Data tab should be selected.
<li>The Series Expression allows you to define an added level of detail to your bar chart. To enter the series expression value:</li>
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Key Expression field.</li>
:The Expression editor window displays.
<li>From the bottom pane, double-click the name of the attribute that contains the data that you would like to include in the chart.</li>
:The expression to represent the attribute displays in the top pane.
<li>In order to account for null values, you will need to modify the expression so that null values are grouped into their own group. The expression should be modified to include the bolded text below. You should replace attribute with the name of the attribute that you selected in step b above.</li>
$F{''attribute''} '''!= null ? $F{attribute} : "Unknown"'''
<li>Click the '''Apply''' button.</li>
</ol>
The expression that you enter in the Series Expression field will vary based on how you want the horizontal axis to appear:
*If you would like the horizontal axis of the bar chart to reflect a single attribute such as the chart displayed in [[:Image:iRep30.png|Figure 30]], the Series Expression will be the same as the Category expression.
</ol>
 
[[Image:iRep30.png|center|500px|''Figure 30. Bar chart –Single attribute y-axis'']]
<div align="center">
''Figure 30. Bar chart –Single attribute y-axis''
</div>
 
<ol>
*If you would like the horizontal axis of the bar chart to reflect the values of an additional attribute, the Series Expression would be the expression for the secondary level of detail. In the example shown in [[:Image:iRep31.png|Figure 31]], the x-axis reflects the hazard priorities (e.g., Low, Medium, or High). In addition to displaying the priority, the bars of the chart use a different colour to reflect those hazards which block water access (red) vs. those that do not block the water (blue).
</ol>
 
[[Image:iRep31.png|center|500px|''Figure 31. Bar chart with different series expression'']]
<div align="center">
''Figure 31. Bar chart with different series expression''
</div>
 
<ol>
The Chart Properties window for this bar chart is shown below (Figure 32). Notice that the series expression and category expression differ.
</ol>
 
[[Image:iRep32.png|center|500px|''Figure 32. Chart Properties – Different series and category expressions'']]
<div align="center">
''Figure 32. Chart Properties – Different series and category expressions''
</div>
 
<ol>
*If you selected one of the stacked bar chart options, the series expression will be used to determine the segments of each bar. In [[:Image:iRep33.png|Figure 33]], the series expression creates red and blue segments in each bar to indicate whether or not water access is blocked.
</ol>
 
[[Image:iRep33.png|center|500px|''Figure 33. Stacked bar chart'']]
<div align="center">
''Figure 33. Stacked bar chart''
</div>
 
<ol start="14">
<li>The Category Expression is the major grouping of the horizontal axis. To enter the category expression:</li>
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Category expression field.</li>
:The Expression editor window displays.
<li>From the bottom pane, double-click the name of the attribute that contains the data that you would like to include in the chart.</li>
:The expression to represent the attribute displays in the top pane.
<li>In order to account for null values, you will need to modify the expression so that null values are grouped into their own group. The expression should be modified to include the bolded text below. You should replace attribute with the name of the attribute that you selected in step b above.</li>
$F{''attribute''} '''!= null ? $F{attribute} : "Unknown"'''
<li>Click the '''Apply''' button.</li>
</ol>
<li>The '''Value Expression''' field contains the expression that returns the numeric value for the key.</li>
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Value Expression field.</li>
:The Expression editor window displays.
<li>From the Objects and expressions tab, select '''Variables''' from the left pane.</li>
<li>From the middle pane at the bottom of the Expression editor window, double-click the name of the variable that was created to store the total.</li>
<li>Click the '''Apply''' button.</li>
</ol>
<li>Click the '''OK''' button.</li>
:The Chart Properties window closes.
<li>Click the '''Close''' button.</li>
:The Chart Properties window closes.
<li>Save the report by either clicking the [[Image:iRepSave.png]] icon, or by selecting the '''Save''' option from the '''File''' menu.</li>
</ol>
 
===Grouped Bar Chart===
The horizontal axis of the bar charts discussed in the previous section compared the values of a single variable. For example, the bar chart below compares the number of different hazard reduction types.
 
[[Image:iRep34.png|center|500px|''Figure 34. Bar chart comparing values of a single variable'']]
<div align="center">
''Figure 34. Bar chart comparing values of a single variable''
</div>
 
In this section, you will learn how to create a grouped bar chart. A grouped bar chart compares the values of a single variable in one group to the same variables in another group. In the example below, the grouped bar chart still compares the number of hazard reduction types. However, the chart also compares the number of hazard reduction types between the districts. The number of hazard reductions types (clearance, impact survey, technical survey, and road clearance) are represented by the different bar colours as indicated in the legend. The coloured bars are clustered together based on their district. The first cluster of bars shows the number of hazard reductions in the Bolikon district. The second cluster of bars shows the number of hazard reductions in the Waltern district.
 
[[Image:iRep35.png|center|500px|''Figure 35. Grouped bar chart comparing values of a single variable'']]
<div align="center">
''Figure 35. Grouped bar chart comparing values of a single variable''
</div>
 
The two main differences between adding a bar chart and a grouped bar chart are:
*The grouped bar chart requires that you specify at least two groupings for the report.
*The key expression and the category expression will differ; whereas, for a bar chart, the value for these expressions is the same.
 
To add a grouped bar chart to the report:
<ol>
<li>Create a report which groups the results by the fields that will be represented on the horizontal axis of the chart.</li>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || For a grouped bar chart, you will need to specify at least two groupings.
|}
 
<ol start="2">
<li>Add any variables that you may need to calculate the value that you would like to show on the chart.</li>
<li>If you would like to display the calculated variable for each group, you should add the footer for the field on which the results will be grouped. This footer will be used to display the variable for the group that will subsequently be used in the chart. To add a group footer:</li>
<ol type="a">
<li>From the '''View''' menu, select '''Bands'''.</li>
:The <FileName> bands… window displays.
<li>Select <''GroupFieldName''>Footer from the left pane where ''GroupFieldNameis'' the name of the field on which the results will be grouped. For example, if you are creating a report on hazards and group the results by the priority, the name of the band would be ''priorityFooter''.</li>
<li>In the right pane, enter a numeric value in the Band Height field. You may adjust the height of the summary.</li>
<li>Click the '''Apply''' button.</li>
<li>Add a summary section to the report.</li>
</ol>
<li>Click the [[Image:iRepBarChart.png]] icon.</li>
<li>In the summary section of the report, hold down the mouse button and drag the cursor to form the rectangle which will contain the chart.</li>
:A window of the various chart options displays.
<li>Select one of the bar chart options.</li>
</ol>
 
[[Image:iRep36.png|center|500px|''Figure 36. Bar chart options'']]
<div align="center">
''Figure 36. Bar chart options''
</div>
 
<ol start="8">
<li>Click the '''OK''' button.</li>
<li>Right-click anywhere on the chart.</li>
<li>select the '''Chart Properties''' option.</li>
<li>From the Chart Properties window, select the Chart Data tab.</li>
<li>From the Chart Data tab, select the Details tab.</li>
<li>Click the '''Add''' button.</li>
:The Chart Properties window displays. By default, the Data tab should be selected.
<li>For a grouped bar chart, the series expression contains the field whose distinct values you would like to show via different colours on the bar chart.</li>
</ol>
 
[[Image:iRep37.png|center|500px|''Figure 37. Bar chart series expression'']]
<div align="center">
''Figure 37. Bar chart series expression''
</div>
 
To enter the series expression:
<ol start="15">
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Key Expression field.</li>
:The Expression editor window displays.
<li>From the bottom pane, double-click the name of the field that contains the data that you would like to include in the chart.</li>
:The expression to represent the field displays in the top pane.
<li>Click the '''Apply''' button.</li>
</ol>
<li>The Category Expression is the field by which the series expression is grouped together.</li>
</ol>
 
[[Image:iRep38.png|center|500px|''Figure 38. Bar chart category expression'']]
<div align="center">
''Figure 38. Bar chart category expression''
</div>
 
To enter the category expression:
<ol start="16">
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Category expression field.</li>
:The Expression editor window displays.
<li>From the bottom pane, double-click the name of the field that contains the data that you would like to include in the chart.</li>
:The expression to represent the field displays in the top pane.
<li>Click the '''Apply''' button.</li>
</ol>
<li>The '''Value Expression''' field contains the variable that returns the numeric value that will be represented on the chart.</li>
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Value Expression field.</li>
:The Expression editor window displays.
<li>From the Objects and expressions tab, select '''Variables''' from the left pane.</li>
<li>From the middle pane at the bottom of the Expression editor window, double-click the name of the variable that you would like to represent on the chart.</li>
<li>Click the '''Apply''' button.</li>
</ol>
<li>Click the '''OK''' button.</li>
:The Chart Properties window closes.
<li>Click the '''Close''' button.</li>
:The Chart Properties window closes.
<li>Save the report by either clicking the [[Image:iRepSave.png]] icon, or by selecting the Save option from the '''File''' menu.</li>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || iReport requires you to save the report after adding or changing a chart.
|}
 
<ol start="20">
<li>Click the [[Image:iRepCompile.png]] button to compile the report.</li>
<li>Click the [[Image:iRepRun.png]] button to execute the report.</li>
</ol>
 
===Stacked Bar Chart===
A stacked bar chart is similar to a grouped bar in that it allows you to represent two different fields on the chart. The key difference is that the stacked bar chart layers the values of the series expression (the field represented in the legend) allowing you to easily compare the categories to one another.
 
[[Image:iRep39.png|center|500px|''Figure 39. Stacked bar chart'']]
<div align="center">
''Figure 39. Stacked bar chart''
</div>
 
To add a grouped bar chart to the report:
<ol>
<li>Create a report which groups the results by the fields that will be represented on the horizontal axis of the chart.</li>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || For a stacked bar chart, you will need to specify at least two groupings.
|}
 
<ol start="2">
<li>Add any variables that you may need to calculate the value that you would like to show on the chart.</li>
<li>If you would like to display the calculated variable for each group, you should add the footer for the field on which the results will be grouped. This footer will be used to display the variable for the group that will subsequently be used in the chart. To add a group footer:</li>
<ol type="a">
<li>From the '''View''' menu, select '''Bands'''.</li>
:The <FileName> bands… window displays.
<li>Select <''GroupFieldName''>Footer from the left pane where ''GroupFieldName'' is the name of the field on which the results will be grouped. For example, if you are creating a report on hazards and group the results by the priority, the name of the band would be ''priorityFooter''.</li>
<li>In the right pane, enter a numeric value in the '''Band Height''' field. You may adjust the height of the summary</li>
<li>Click the '''Apply''' button.</li>
</ol>
<li>Add a summary section to the report.</li>
<li>Click the [[Image:iRepBarChart.png]] icon.</li>
<li>In the summary section of the report, hold down the mouse button and drag the cursor to form the rectangle which will contain the chart.</li>
:A window of the various chart options displays.
<li>Select one of the stacked bar chart options.</li>
</ol>
 
[[Image:iRep40.png|center|500px|''Figure 40. Stacked bar chart options'']]
<div align="center">
''Figure 40. Stacked bar chart options''
</div>
 
<ol start="8">
<li>Click the '''OK''' button.</li>
<li>Right-click anywhere on the chart.</li>
<li>Select the '''Chart Properties''' option.</li>
<li>From the Chart Properties window, select the Chart Data tab.</li>
<li>From the Chart Data tab, select the Details tab.</li.
<li>Click the '''Add''' button.</li>
:The Chart Properties window displays. By default, the Data tab should be selected.
<li>For a stacked bar chart, the series expression contains the fields whose distinct value.</li>
<li>For a grouped bar chart, the series expression contains the field whose distinct values you would like to show via different colours on the bar chart. To enter the series expression:</li>
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Key Expression field.
:The Expression editor window displays.</li>
<li>From the bottom pane, double-click the name of the field that contains the data that you would like to include in the chart.</li>
:The expression to represent the field displays in the top pane.
<li>Click the '''Apply''' button.</li>
</ol>
<li>The Category Expression is the field by which the series expression is grouped together. To enter the category expression:</li>
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Category expression field.</vli>
:The Expression editor window displays.
<li>From the bottom pane, double-click the name of the field that contains the data that you would like to include in the chart.</li>
The expression to represent the field displays in the top pane.
<li>Click the Apply button.</li>
</ol>
<li>The '''Value Expression''' field contains the variable that returns the numeric value that will be represented on the chart.</li>
<ol type="a">
<li>Click the [[Image:iRepEditor.png]] icon that is displayed beside the Value Expression field.</li>
:The Expression editor window displays.
<li>From the Objects and expressions tab, select '''Variables''' from the left pane.</li>
<li>From the middle pane at the bottom of the Expression editor window, double-click the name of the variable that you would like to represent on the chart.</li>
<li>Click the '''Apply''' button.</li>
</ol>
<li>Click the '''OK''' button.</li>
:The Chart Properties window closes.
<li>Click the '''Close''' button.</li>
:The Chart Properties window closes.
<li>Save the report by either clicking the [[Image:iRepSave.png]] icon, or by selecting the '''Save''' option from the '''File''' menu.</li>
<li>Click the [[Image:iRepCompile.png]] button to compile the report.</li>
<li>Click the [[Image:iRepRun.png]] button to execute the report.</li>
</ol>
0
edits