Changes

Jump to: navigation, search

Summarize iReport Template Data

10,951 bytes removed, 15:04, 13 November 2015
no edit summary
==Editing Summarizing Report Data=====Adding a Footer or Summary Section to the Report===Totals, averages, and other summary data are typically found at the end of a grouping or at the end of a report. You may add a section—or ''band'' as it is referred to in iReport—by doing the following:{{TOC right}}
<ol>==Summarising Report Data==__NOEDITSECTION__<li>From In addition to displaying report details in an iReport template, the iReport Designer allows creating summaries or calculations of data returned in the report. These can take the form of totals, sums, and counts (stored in variables), or more complicated data summaries such as crosstabs or charts. Because summarizing data necessarily depends on multiple records, data summaries must exist in bands ''after'View''' menuthe Detail band such as the Summary band, Footer band, select '''Bands'''or Group Footer bands.</li>:The <FileName> bands… window displays. <li>Do one of ===Adding a Footer or Summary Section to the following:</li>Report===__NOEDITSECTION__*If you would like to add a footer Totals, averages, and other summary data are typically found at the end of a grouping, select or at the <''GroupAttribute''>Footer from the left pane where ''GroupAttribute'' is the name end of the attribute on which the results will be groupeda report. For example, if you are creating If a report desired band is not visible on hazards and group the results by iReport Designer canvas:# Select the priority, desired band in the name of the band would be priorityFooter.*If you would like to add a summary section, select ''summary'Report Inspector''' from the left pane. <li># In the right pane, enter a numeric value in the '''Band HeightProperties''' field. The height of the section may also be adjusted later.</li><li>Click pane, change the '''ApplyBand Height''' buttonproperty to something more than 0 (e.g.</li>:The section is added to the report50). </ol>
===Displaying Counts===__NOEDITSECTION__
iReport has a built-in variable for calculating the number of records in a report and the number of records in each group if the report contains groups. The number of records in the report is stored in the REPORT_COUNT variable. The number of records in each group is stored in the <''GroupField''>_COUNT where GroupField is the name of the field on which the group is created.
<ol>
<li>Expand the appropriate section to the report. If you would like to add the number of records in the report, you will need to expand the summary section of the report. If you would like to add the number of records for each group, you will need to expand the <''GroupField''>Footer section.</li>
<li>From the '''ViewReport Inspector''' menu, select '''Variables'''.</li>
:The REPORT_COUNT variable will always be available in the Variables list. The variable to display the count for the group will only be displayed if the report contains groups.
<li>To display the number of records in your report, drag the REPORT_COUNT variable to the summary section of the report.</li>
</ol>
[[Image:iRep22.png|center|500px|''Figure 22. REPORT_COUNT element in summary section'']]
<div align="center">
''Figure 22. REPORT_COUNT element in summary section''
</div>
{| class="wikitable"|-| [[File:Note.jpg | 40px]] |{note| If the REPORT_COUNT element is dragged to a section of the report other than the summary, the value returned by the REPORT_COUNT variable will be determined by where it is placed. For example, if the REPORT_COUNT is placed in the pageFooter section, the value returned will be the number of records displayed so far. |}}
<olstart="4">
<li>To display the number of records in each group, drag the <GroupName>_COUNT variable to the <''GroupName''>Footer section.</li>
</ol>
{| class="wikitable"|-| [[File:Note.jpg | 40px]] |{note| It may be helpful to add a text label beside any counts that you add to the report to identify the value. To add a text label, click drag the static text element [[Image:iRepText.png]] iconfrom the '''Palette''' pane. |}}
===Displaying Totals===__NOEDITSECTION__iReport allows you to display the total of a particular attribute in the report. This is done by creating a variable to store the total value (see [[Modify an iReport Template#Adding a Variable to an iReport Template| Adding a Variable to an iReport]]).
To display a total:
<ol>
<li>Ensure that a group footer or summary section has been added to the report.</li>
<li>From the Library pane, click [[Image:iRepTotal.png]].</li></ol> {| class="wikitable"|-| [[File:Note.jpg | 40px]] || If the Library pane is not displayed, display it by doing the following:<ol><li>From the '''ViewReport Inspector''' menupane, select choose '''Docking PanesVariables'''.</li><li>From and drag the '''Docking Panes''' menu, select '''Library'''.</li></ol>|} <ol start="3"><li>Drag the [[Image:iRepTotal.png]] variable to the footer or summary section of the report. If you drag it to the footer, the total for the values in the group will be calculated. If you drag it to the summary, the total for all values will be calculated.</li>:A window displays to allow you to select the object to sum ([[:Image:iRep23.png]]).</ol> [[Image:iRep23.png|center|500px|''Figure 23. Window to select object to sum'']]<div align="center">''Figure 23. Window to select object to sum''</div> <ol><li>Double-click ''Fields''.</li><li>Click the name of the attribute that you would like to sum.</li><li>Click the '''OK''' button.</li>
</ol>
===Creating Custom Variables===In addition to the built-in functions to calculate the number of records and the sum of a field, iReport also allows you to define a other types of variablecalculations. A variable is a named object that stores the result of a calculation. iReport allows you to define new variables and how those variables should be calculated. For example, you may define a variable that calculates the average for a particular field such as the area size. Or, you may wish to display the maximum value of a field. In these situations, you may define a custom variable.
To create a custom variable:
<ol><li>From # Follow the '''View''' menu, select '''Variables'''.</li><li>Click the '''New''' button.</li>:The Add/modify variable window displays.</ol> steps to [[Image:iRep24.pngModify an iReport Template#Adding a Variable to an iReport Template|center|500px|''Figure 24. Add/modify add a variable window''to an iReport]]<div align="center">''Figure 24. Add/modify variable window''</div> <ol start="3"><li>In the '''Variable Name''' field, enter a name for the variable. You should provide a name that is meaningful and indicative of what the value returns.</li><li># From the '''Variable Class Calculation Type''' list, select the data type of the resulting value. The variable class type will depend on the field that you are using in the calculation.</li></ol> {| class="wikitable"|-| [[File:Note.jpg | 40px]] || To determine the class type of a field:<ol><li>Right-click the field element in the report pane.</li><li>Select '''Properties'''.</li><li>Select the '''Text Field''' tab.</li>:The class type will be displayed in the '''Text Field Expression Class''' field. </ol>|} <ol start="5"><li>From the '''Calculation Type''' listpane, select the calculation that you would like to perform.</li></ol>
<center>
{| class="wikitable" width="600"
|-
| align="center" colspan="2" | '''Table 4. Calculation types'''
|-
| width="150pt" | '''Calculation type'''
|-
| System || No calculation is made. Instead the last value is stored.
|-
| First || No calculation is made. Instead the first value is stored.
|}
</center>
<ol start="63">
<li>From the Reset Type list, select when a variable value should be reset to the initial value. For example, suppose you wanted to count the number of accidents in each location. Each time a new group—in this case a location—is encountered, the variable should be reset. To do this, you would need to reset the value of the variable after each group.</li>
</ol>
{| class="wikitable" width="600"
|-
| align="center" colspan="2" | '''Table 5. Reset Types'''
|-
| width="150pt" | '''Reset Type'''
</center>
<ol start="74">
<li>If you select ''Group'' as the '''Reset Type''', you will need to select the group on which you would like to reset the variable from the '''Reset Group''' list. The '''Reset Group''' list will contain all fields on which the report is grouped.</li>
</ol>
[[Image:iRep25.png|center|500px|''Figure 24. Add/modify variable window'']]
<div align="center">
''Figure 25. Reset Type and Reset Group''
</div>
{| class="wikitable"|-| [[File:Note.jpg | 40px]] |{note| If the field on which the variable should be reset is not listed in the Reset Group list, be sure that the field is included as one of the grouping levels for the report. |}}
<ol start="85"><li>From the '''Increment Type''' list, select the increment at which the value will need to be evaluated. It is useful when you want to calculate sub-totals.</li><li>From the '''Increment Group''' list, select the group at which the variable will be incremented.</li><li>The '''Variable Expression''' field specifies the expression that will be provided to the variable. Typically, this will be the value of a field in the report. To specify a field in the report:</li><ol type="a"><li>Click the [[Image:iRepEditor.png]] button that is displayed beside edit the '''Variable Expression''' field.</li>[[Image:The Expression editor window displaysIReport VariableAdd5.<li>From the Objects and expressions tab, select png|center|500px|''Variable Expression Editor'Fields''' from the left pane.]]</lidiv align="center"><li>From the middle pane at the bottom of the Expression editor window, double-click the name of the field that you would like to use in the calculation.</li><li>Click the '''Apply''' button.</li>:The Expression editor window closes. The Add/modify variable window displays the selected field in the Variable Expression field. <li>Click the '''OKEditor''' button.</lidiv>:The Add/modify variable window closes and the variable that you just added is listed as a variable in the Library pane.</olli>
</ol>
In addition to the summary functions available on the variable, specific expressions can be used in the Expression Editor to define values. For example:{| class="wikitable" width="600" align="center"
|-
| [[File:Note.jpg align="center" colspan="2" | 40px]] || If the Library pane is not displayed, display it by doing the following:<ol><li>From the '''ViewExpression Operations''' menu, select |-| width="150pt" | '''Docking PanesOperation'''.</li><li>From the | width="450pt" | '''Docking PanesExpression''' menu, select '''Library'''.</li></ol>|-|Division || $F{areaSize<ol start="11"><li>From the Library pane, click the name of the variable that you created for the average.</li>$V{REPORT_COUNT}<li>Drag the variable to the summary section of the report.</li>|-</ol> ==Charts== Charts provide a visual representation of the report data| Addition || $F{areaSize} + 500. 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"0
|-
| [[File:Note.jpg Subtraction | 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''areaSize} '''!= null ? - $FP{''attribute''ClearedArea} : "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 Multiplication | 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{attributeareaSize} : "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 ? $FV{attributeREPORT_COUNT} : "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 Concatenation (string only)| 40px]] || For a grouped bar chart, you will need to specify at least two groupings. $F{localId} + $P{LocationName}
|}
<ol start="2">=Crosstabs==__NOEDITSECTION__<li>Add any In addition to summary variables that you may need , iReport provides the capability to calculate the value build crosstab tables that you would like to show on the chartdisplay data in a grid for easy analysis and summary.</li><li>If Crosstabs allow you would like to display choose data rows, columns, and 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 measured and then automatically produce 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 grid of the field on which the results will be groupedfor display in a chart. For example, if you As with other summary variables Crosstabs are creating a report on hazards and group generally used in 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 Summary Band Height field. You may adjust the height of the summary.</li><li>Click the '''Apply''' button.</li><li>Add in 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>
To create a Crosstab:# In the '''Palette''' pane, drag a '''Crosstab''' item to the Summary Band of the report.# The Crosstab wizard displays#: [[Image:iRep36IReport Crosstab1.png|center|500px|''Figure 36Crosstab wizard'']]<div align="center">''Crosstab wizard''</div># Select the '''Field''' to use in the '''Row''' of the Crosstab grid.#: [[Image:IReport Crosstab2. Bar chart optionspng|center|500px|''Crosstab wizard'']]<div align="center">''Crosstab wizard''</div># Select the '''Field''' to use in the '''Column''' of the Crosstab grid.#: [[Image:IReport Crosstab3.png|center|500px|''Crosstab wizard'']]<div align="center">''Crosstab wizard''</div># Select the '''Field''' or '''Variable''' to use to represent the data in the grid. Typically this is a numeric field (e.g. areaSize) or if a count of the records is desired, the ''REPORT_COUNT''Figure 36variable.#: [[Image:IReport Crosstab4.png|center|500px|''Crosstab wizard'']]<div align="center">''Crosstab wizard''</div># Finalise the Crosstab display.#: [[Image:IReport Crosstab5. Bar chart optionspng|center|500px|''Crosstab wizard'']]<div align="center">''Crosstab wizard''</div># The Crosstab displays.#: [[Image:IReport Crosstab6.png|center|500px|''Crosstab wizard'']]<div align="center">''Crosstab wizard''</div>
<ol start="8"><li>Click The report can now be run or additional adjustments to the '''OK''' buttonreport can be made including resizing columns and rows, number formatting, or display adjustments.</li><li>Right-click anywhere on the chart[[Image:IReport Crosstab7.</li><li>select the png|center|500px|''Crosstab Preview'Chart Properties''' option.]]</li><li>From the Chart Properties window, select the Chart Data tab.</li><lidiv align="center">From the Chart Data tab, select the Details tab.</li><li>Click the ''Example Crosstab Preview'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></oldiv>
[[Image:iRep37.png|center|500px|''Figure 37. Bar chart series expression'']]<div align="center">''Figure 37. Bar chart series expression''</div>=Charts==__NOEDITSECTION__
To enter Charts provide a visual representation of the series expressionreport data. Before you add a chart to your report, you should ensure that your report contains the following:<ol start="15"><ol type="a"><li>Click the #At least one grouping. The report groupings are used by iReport to determine what fields may be plotted. See [[Modify an iReport Template|Modify an iReport Template]] for more information on [[Image:iRepEditor.pngModify an iReport Template#Grouping|grouping]] icon that is displayed beside the Key Expression field.</li>:The Expression editor window displays#At least one variable that contains a calculation.<li>From the bottom paneThis calculation may be a count, total, double-click or other custom calculation. These calculated variables define the name size of the field that contains the data that you would like to include in the chartsegment.</li>:The expression '''Reset type''' of this calculation should be set to represent the field displays in the top pane.<li>Click the '''ApplyGroup''' buttonand use the report grouping defined in #1.</li></ol><li>The Category Expression is the field by which the series expression is grouped togetherSee [[Modify_an_iReport_Template|Modify an iReport Template]] for more information on [[Modify_an_iReport_Template#To_add_a_variable_manually|adding variables]].</li></ol>
[[Image:iRep38.png|center|500px|''Figure 38. Bar chart category expression'']]<div align="center">''Figure 38. Bar chart category expression''</div>==Pie Chart===__NOEDITSECTION__
====Add a Pie Chart====__NOEDITSECTION__To enter add a pie chart to the category expressionreport:<ol start="16"><ol type="#Create a">report which groups the results by the attribute on which you would like to base your chart (e.g. ''status'').<li>Click #Ensure that the Summary Band is available on the iReport template canvas.#[[Image:iRepEditor.pngModify_an_iReport_Template#Adding a Variable to an iReport Template|Create a Variable]] icon that is to contain the values to be displayed beside in the chart (e.g. ''SUM_areaSize_byStatus''). This variable should be based on a numeric field (e.g. ''areaSize'') and should have the '''Reset type''' set to '''Group''' and the group selected set to the Category expression fieldyou wish to create the chart from'' (e.</li>:The Expression editor window displaysg. ''status'').<li>From #Select the '''Chart''' option from the bottom '''Palette''' pane, double-click and drag it to the name '''Summary Band''' of the field that contains report template to start the data that you would like to include in '''Chart Wizard'''.#Select one of the pie chartoptions.#:[[Image:iReport Charts1.png|center|500px|''Chart options'']]<div align="center">''Chart options''</lidiv>#Choose Main report dataset.#:[[Image:iReport Charts2.png|center|500px|''Chart options'']]<div align="center">''Chart options''</div># The expression next step is to represent provide the field displays in correct data for the top panechart to use.<li>Click the Pie Charts require a '''unique identifier''' and a '''Applynumeric''' buttonvalue where the unique identifier is the field to group the data by (i.e. the names of the wedges) and numeric value is the value to sum. #:[[Image:iReport Charts3.png|center|500px|''Chart options'']]</lidiv align="center">''Chart options''</oldiv><li>The # To select the '''unique value''' choose the '''Value Expressioneditor''' button and '''choose the '' field contains '' the variable report is grouped by''' (e.g. ''status''). Note that returns charts in iReport will fail if the numeric '''unique value ''' is null. In order to account for null values, you will need to modify the expression so that will null values are grouped into their own group. The expression should be represented on modified to include the chartbolded text below.</li> <ol type#: '''$F{status} ==null ? "aN/A">: $F{status}'''<li>Click the #:[[Image:iRepEditoriReport Charts5.png|center|500px|''Set Unique Value'']] icon that is displayed beside the <div align="center">''Set Unique Value Expression field.''</lidiv>:The Expression editor window displays.<li>From the Objects and expressions tab#Next, select the '''Variablesnumeric value''' from that contains the desired numeric data for the chart. '''Note: This should always be the left panevariable created in step 3 above''' (e.g. ''SUM_areaSize_byStatus'').</li>#:[[Image:iReport Charts6.png|center|500px|''Select the desired numeric variable'']]<lidiv align="center">From the middle pane at the bottom of the Expression editor window, double-click the name of ''Select the desired numeric variable that you would like to represent on the chart.''</lidiv><li>Click the #Choose '''ApplyNext''' button.#:[[Image:iReport Charts7.png|center|500px|''Chart Wizard Completed'']]</lidiv align="center">''Chart Wizard Completed''</oldiv><li>Click the # Choose '''OKFinish''' buttonand the iReport template displays with the Chart.</li>#:The [[Image:iReport Charts8.png|center|500px|''iReport displays with Chart Properties window closes.'']]<lidiv align="center">Click the '''CloseiReport displays with Chart''' button.</lidiv>:# The Chart Properties window closesreport can now be previewed to ensure it is functioning as expected.<li>Save the report by either clicking the #:[[Image:iRepSaveiReport ChartsPreview.png|center|500px|''Preview with Chart'']] icon<div align="center">''Preview with chart''</div>====Modify a Pie Chart====__NOEDITSECTION__Once a chart has been created in iReport Designer, or its properties can be edited by selecting the Save option from the '''FileChart Data''' option on the right click menuand adjusting the values and properties.</li></ol>
{To modify a chart:# Right click on the chart in iReport Designer and select '''Chart Data''' from the menu.# The Chart details window displays.#: [[Image:IReport ChartData1.png|center|500px| class''Chart Data Properties'']]<div align="wikitablecenter">''Chart Data Properties''</div>|-# To edit the main properties of the chart, select the '''Details tab'''. Additionally, this screen can be used to edit the reset type of the chart which is relevant if the chart is displayed on a band other than the summary band.# The '''Chart Details''' window displays.| #: [[FileImage:NoteIReport ChartData2.jpg png| 40pxcenter|500px|''Chart Data Properties'']] || iReport requires you <div align="center">''Chart Data Properties''</div># In this window, the basic properties of the chart that were established in the Chart Wizard can be edited. These include:#* '''Key Expression''': the field used to save group data for charting purposes. To change the field, simply select another field. '''Note:''' The field must be used in the report after adding creation of the variable used in the value expression or changing a the results will be incorrect.#* '''Value Expression''': the variable used to store the data to be displayed in the chart. If changes are made this value it is recommended to edit the variable properties as well. #* '''Label Expression''': the area used to define the labels for the chart. Any valid expression can be used here. See [[Summarize iReport Template Data#Variable Expressions|}Variable Expressions]] for more details.
<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 ChartCharts===__NOEDITSECTION__A stacked bar chart is similar to Bar charts, unlike Pie Charts, have a grouped bar third variable option that can be included in that it allows you to represent two different fields on the chartreport. The key difference is that In addition to the stacked category and value expressions, bar chart layers charts add the values option of the a '''''series'''''. The series expression (the field represented in the legend) allowing you to easily compare the categories to one anotherchoice adds an additional possibility of grouping data though is not required.
====Add a Bar Chart====__NOEDITSECTION__To add a bar chart to the report:#Create a report which groups the results by the attribute on which you would like to base your chart (e.g. ''status'')#Ensure that the Summary Band is available on the iReport template canvas.#[[Modify_an_iReport_Template#Adding a Variable to an iReport Template|Create a Variable]] to contain the values to be displayed in the chart (e.g. ''SUM_areaSize_byStatus''). This variable should be based on a numeric field (e.g. ''areaSize'') and should have the '''Reset type''' set to '''Group''' and the group selected set to the field you wish to create the chart from'' (e.g. ''status'').#Select the '''Chart''' option from the '''Palette''' pane and drag it to the '''Summary Band''' of the report template to start the '''Chart Wizard'''.#Select one of the bar chart options.#:[[Image:iRep39IReport BarChart.png|center|500px|''Figure 39Chart options'']]<div align="center">''Chart options''</div>#Choose Main report dataset. Stacked bar chart#:[[Image:IReport BarChart_Step1.png|center|500px|''Chart options'']]<div align="center">''Chart options''</div># Provide a ''Figure 39'Series Expression''' (''optional''). Stacked #:[[Image:iReport Chart Bar1.png|center|500px|''Series Expression'']]<div align="center">''Series Expression''</div># The Series Expression allows you to define an added level of detail to your bar chart(if desired). To select the '''Series''' choose the '''Expression editor''' button and '''choose one of the ''fields'' the report is grouped by'''(e.g. ''status''). Note that charts in iReport will fail if the '''Series''' value is null. 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 the field the name of the field that you selected above.#: '''$F{status} == null ? "N/A" : $F{status}'''#:[[Image:iReport Charts5.png|center|500px|''Set Series Value'']]<div align="center">''Set Series Value''</div>#: The expression that you enter in the Series Expression field will vary based on how you want the horizontal axis to appear:To add a grouped #*If you would like the horizontal axis of the bar chart to reflect a single attribute such as the reportchart displayed below, the Series Expression will be the same as the Category expression.#:[[Image:iRep30.png|center|500px|''Bar chart –Single attribute y-axis'']]<oldiv align="center">''Bar chart –Single attribute y-axis''<li/div>Create a report which groups #*If you would like the horizontal axis of the bar chart to reflect the results by values of an additional attribute, the fields that will Series Expression would be represented on the horizontal expression for the secondary level of detail. In the example shown below, the x-axis reflects the land priorities (e.g., Low, Medium, or High). In addition to displaying the priority, the bars of the chartuse a different colour to reflect those land which block water access (red) vs. those that do not block the water (blue). #:[[Image:iRep31.png|center|500px|''Bar chart with different series expression'']]<div align="center">''Bar chart with different series Expression''</lidiv>#* '''Finally, the Series value can be left blank if desired.'''# The next step is to provide the correct data for the chart to use. Bar charts require a '''category expression''' and a '''value expression''' where the value expression is a field to group the data by (i.e. the names of the X axis) and value expression is the value to sum. #:[[Image:iReport Chart Bar2.png|center|500px|''Category and Values'']]<div align="center">''Category and Values''</oldiv># To select the '''category expression''' choose the '''Expression editor''' button and '''choose one of the ''fields'' the report is grouped by''' (e.g. ''status''). Note that charts in iReport will fail if the '''category expression''' is null. 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 field with the field that you selected above.#: '''$F{status} == null ? "N/A" : $F{status}'''#:[[Image:iReport Charts5.png| classcenter|500px|''Set Category Expression'']]<div align="wikitablecenter">''Set Category Expression''</div>|-#Next, select the '''value expression''' that contains the desired numeric data for the chart. '''Note: This should always be one of the variables created in step 3 above''' (e.g. ''SUM_status_byAreaSize''). | #:[[FileImage:NoteiReport Charts6.jpg png| 40pxcenter|500px|''Select the desired value expression'']] <div align="center">''Select the desired value expression''</div># Choose '''Finish''' and the iReport template displays with the Chart.#:[[Image:iReport Chart Bar3.png|center| For a stacked bar chart, you will need 500px|''iReport displays with Chart'']]<div align="center">''iReport displays with Chart''</div># The report can now be previewed to specify at least two groupingsensure it is functioning as expected. #:[[Image:iReport Chart BarPreview.png|}center|500px|''Preview with Chart'']]<div align="center">''Preview with chart''</div>
<ol start="2">===Modify a Bar Chart====__NOEDITSECTION__<li>Add any variables that you may need to calculate the value that you would like to show on the Once a bar chart.</li><li>If you would like to display the calculated variable for each grouphas been created in iReport Designer, you should add the footer for the field on which the results will its properties can be grouped. This footer will be used to display the variable for the group that will subsequently be used in edited by selecting 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 'Chart Data'GroupFieldName'' is the name of the field option on which the results will be grouped. For example, if you are creating a report on hazards right click menu and group adjusting 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 values 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 optionsproperties.</li></ol>
To modify a bar chart:# Right click on the chart in iReport Designer and select '''Chart Data''' from the menu.# The Chart Data properties display.# To edit the main properties of the chart, select the '''Details tab'''. Additionally, this screen can be used to edit the reset type of the chart which is relevant if the chart is displayed on a band other than the summary band.# The '''Chart Details''' window displays#: [[Image:iRep40IReport Chart Bar ChartData1.png|center|500px|''Figure 40. Stacked bar chart optionsChart Data Properties'']]<div align="center">''Chart Data Properties''</div># For Bar Charts this presents the ''Figure 40'Category Series''' chooser. Stacked bar chart optionsTypically there will be only one or two series to choose from here though more can be added at this point. Select the series to modify and choose '''Modify'''.# The Chart Data properties window will display#: [[Image:IReport Chart Bar ChartData2.png|center|500px|''Chart Data Properties'']]<div align="center">''Chart Data Properties''</div># In this window, the basic properties of the bar chart that were established in the Chart Wizard can be edited. These include:#*'''Series Expression''': the field used to first group data for charting purposes. To change the field, simply select another field. '''Note:''' while this field is required it can be made blank or fixed by being set to a constant such as: "" or "Blank".#*'''Category Expression''': the field used to group data for charting purposes. To change the field, simply select another field. '''Note:''' The field must be used in the creation of the variable used in the value expression or the results will be incorrect.#* '''Value Expression''': the variable used to store the data to be displayed in the chart. If changes are made this value it is recommended to edit the variable properties as well.#* '''Label Expression''': the area used to define the labels for the chart. Any valid expression can be used here. See [[Summarize iReport Template Data#Variable Expressions|Variable Expressions]] for more details.
<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 {{NavBox HowTo Standardizing 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">Analysis and Information Reporting}}<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.pngVIE]] 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>
4,913
edits

Navigation menu