Java Reference
In-Depth Information
To populate the dataset parameters with the desired report expression, we need
to use the <crosstabDataset> element inside the <crosstab> . This element
must contain a single <dataset> element, which in turn contains a <datasetRun>
element. This element contains a name attribute indicating which subdataset to use
to populate the crosstab; it also contains a <datasetParameterExpression> sub-
element indicating what report element to use to populate the dataset parameter.
Subdatasets can also be used in a similar manner to create related charts in each
report record. To accomplish this, the <dataset> element must be placed inside the
appropriate dataset element for the chart ( <categoryDataset> , <pieDataset> , etc).
The following example demonstrates this feature for a bar chart. The report generated
by the JRXML template will display a bar chart illustrating the number of aircraft
registered in the states of Maryland, New York, and Virginia.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//
EN" "">
<jasperReport name="ChartDatasetDemoReport" leftMargin="5"
<subDataset name="Aircraft_Registrations">
<parameter name="StateParam" class="java.lang.String"/>
<![CDATA[select, count(*) as aircraft_count
from aircraft a
where a.state=$P{StateParam}
and like 'A%'
group by city]]>
<field name="aircraft_count" class="java.lang.Integer"/>
<field name="city" class="java.lang.String"/>
<![CDATA[select distinct state from aircraft where state in ('MD',
'NY', 'VA') order by state]]>
<field name="state" class="java.lang.String"/>
<band height="200">
<reportElement x="0" y="10" width="500" height="20"/>
Search WWH ::

Custom Search