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. See [[Modify an iReport Template#Grouping|Modify an iReport Template]] for more information on [[Modify an iReport Template#Grouping|grouping]].#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. The '''Reset type''' of this calculation should be set to '''Group''' and use the report grouping defined in #1. See [[Modify_an_iReport_Template#To_add_a_variable_manually|Modify an iReport Template]] for more information on [[Modify_an_iReport_Template#To_add_a_variable_manually|adding variables]].
===Pie Chart===__NOEDITSECTION__
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(e.</li>g. ''status'')<li>After creating #Ensure that the Summary Band is available on the report, you should add iReport template canvas.#[[Modify_an_iReport_Template#Adding a Variable to an iReport Template|Create a footer for Variable]] to contain the attribute on which values to be displayed in the results will be groupedchart (e.g. ''SUM_areaSize_byStatus''). This footer will variable should be used based on a numeric field (e.g. ''areaSize'') and should have the '''Reset type''' set to '''Group''' and the group selected set to display the total for 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 group that will subsequently be used in '''Chart Wizard'''.#Select one of the pie chartoptions. To add a group footer#:[[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'']]<ol typediv align="acenter">''Chart options''<li/div>From # The next step is to provide the correct data for the chart to use. Pie Charts require a '''Viewunique identifier''' menu, select and a '''Bandsnumeric'''value 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.</li>#:The <FileName> bands… window displays[[Image:iReport Charts3. png|center|500px|''Chart options'']]<lidiv align="center">Select <''GroupAttributeChart options''</div>Footer from # To select the left pane where ''GroupAttribute'unique value''' is choose the name of '''Expression editor''' button and '''choose the attribute on which ''field'' the results report is grouped by''' (e.g. ''status''). Note that charts in iReport will be groupedfail if the '''unique value''' is null. For exampleIn order to account for null values, if you will need to modify the expression so that null values are creating a report on land and grouped into their own group . The expression should be modified to include the results by the priority, bolded text below. You should replace attribute with the name of the band would be attribute that you selected in step b above.#: '''$F{status} == null ? "N/A" : $F{status}'priorityFooter''#:[[Image:iReport Charts5.png|center|500px|''Set Unique Value'']]<div align="center">''Set Unique Value''</lidiv><li>In #Next, select the right pane, enter a '''numeric value in ''' that contains the Band Height field. You may adjust desired numeric data for the height of the summarychart.</li><li>Click '''Note: This should always be the variable created in step 3 above'''Apply(e.g. ''SUM_status_byAreaSize'' button). #:[[Image:iReport Charts6.png|center|500px|''Select the desired numeric variable'']]</lidiv align="center">''Select the desired numeric variable''</oldiv><li>Add a summary section to the report#Choose '''Next'''.</li><li>Click the #:[[Image:iRepBarChartiReport Charts7.png|center|500px|''Select the desired numeric variable'']] icon.</lidiv align="center"><li>In ''Select the summary section of the report, hold down the mouse button and drag the cursor to form the rectangle which will contain the chart.desired numeric variable''</lidiv># Choose '''Finish'''.#:A window of [[Image:iReport Charts8.png|center|500px|''Select the various chart options displays.desired numeric variable'']]<lidiv align="center">''Select one of the pie chart options.</li>desired numeric variable''</oldiv>
[[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 land 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 land size of high priority land.</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>The following figure is an example of the Chart Properties window for a report that contains a pie chart which graphs the total area size of land based on their priority.</li>