我使用以下xml创建了一个jasper报告,
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="SUB_MS_ICM_SUMMERY" language="groovy" pageWidth="842" pageHeight="590" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="0.75"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<subDataset name="incident_category_1">
<parameter name="start_date" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="end_date" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select category,count from (SELECT 'Total' As category,COUNT(*) as count FROM ms_icm_incident i
where incident_category<>3 and status <> 'Cancelled' and (trunc(nvl(i.initiated_on,$P{start_date})) between to_char(to_date($P{start_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy') and to_char(to_date($P{end_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy'))
union
select decode(inc.incident_category,1,'Actual Incident',2,'Near Hit')
,count(inc.incident_id) as cnt
from ms_icm_incident inc
where inc.incident_category <>3 and inc.status<>'Cancelled'
and (trunc(nvl(inc.initiated_on,$P{start_date})) between to_char(to_date($P{start_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy') and to_char(to_date($P{end_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy'))
group by inc.incident_category
union
SELECT decode(lov.STORED_VALUE,1,'Actual Incident',2,'Near Hit') as incident_category, 0 as cnt
FROM ms_local_lov_t lov
WHERE LOV_NAME='MS_ICM_CATEGORY' and lov.STORED_VALUE <>3
and lov.STORED_VALUE not in (select inc.incident_category
from ms_icm_incident inc
where inc.incident_category <>3 and inc.status<>'Cancelled'
and (trunc(nvl(inc.initiated_on,$P{start_date})) between to_char(to_date($P{start_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy') and to_char(to_date($P{end_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy'))))
order by decode(category,'Total',1 )]]>
</queryString>
<field name="CATEGORY" class="java.lang.String"/>
<field name="COUNT" class="java.math.BigDecimal"/>
</subDataset>
<subDataset name="incident_severity_1">
<parameter name="start_date" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="end_date" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select severity, sum(cnt) from
(select POTENTIAL_SEVERITY_CALCULATED as severity, count(*) as cnt
from ms_icm_incident where incident_category<>3 and POTENTIAL_SEVERITY_CALCULATED is not null and status <> 'Cancelled' and(trunc(nvl(initiated_on,$P{start_date})) between to_char(to_date($P{start_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy') and to_char(to_date($P{end_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy'))
group by POTENTIAL_SEVERITY_CALCULATED)
dual group by severity
order by decode(severity,'High',1,'Medium',2,'Low',3)]]>
</queryString>
<field name="SEVERITY" class="java.lang.String"/>
<field name="SUM(CNT)" class="java.math.BigDecimal"/>
</subDataset>
<subDataset name="Incident_status_1">
<parameter name="start_date" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="end_date" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select status,cnt from (select status, count(*) as cnt from ms_icm_incident
where incident_category<>3 and (trunc(nvl(initiated_on,$P{start_date})) between to_char(to_date($P{start_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy') and to_char(to_date($P{end_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy'))and status <> 'Cancelled'
group by status
union
select status, cnt from (select distinct status,0 as cnt from ms_icm_flow_action_status
union
select 'Closed',0 as cnt from dual) where STATUS NOT IN
(select status from ms_icm_incident
where incident_category<>3 and (trunc(nvl(initiated_on,$P{start_date})) between to_char(to_date($P{start_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy') and to_char(to_date($P{end_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy'))and status <> 'Cancelled'
group by status)and status not in ( 'Cancelled','OHS Investigating','Initiating Incident')
)
order by decode (status,
'Initiated',1,
'Initiated - Need More Info',2,
'Preliminary',3,
'Investigating',4,
'Draft Report Review',5,
'Final Report Review',6,
'Re-Investigating',7,
'Final',8,
'Closed',9,
'Completed',10)]]>
</queryString>
<field name="STATUS" class="java.lang.String"/>
<field name="CNT" class="java.math.BigDecimal"/>
</subDataset>
<parameter name="start_date" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="end_date" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT 'Total' As category,COUNT(*) as count FROM ms_icm_incident i
where incident_category<>3 and (trunc(nvl(i.initiated_on,$P{start_date})) between to_char(to_date($P{start_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy') and to_char(to_date($P{end_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy'))
union
select (SELECT lov.DISPLAYED_VALUE
FROM ms_local_lov_t lov
WHERE lov.STORED_VALUE=i.incident_category
and LOV_NAME='MS_ICM_CATEGORY')as category, count(*) from ms_icm_incident i
where incident_category<>3 and (trunc(nvl(i.initiated_on,$P{start_date})) between to_char(to_date($P{start_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy') and to_char(to_date($P{end_date},'mm/dd/yyyy HH24:MI:SS'),'dd-MON-yyyy'))
group by incident_category]]>
</queryString>
<field name="CATEGORY" class="java.lang.String"/>
<field name="COUNT" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="505">
<barChart>
<chart isShowLegend="false">
<reportElement x="15" y="191" width="772" height="280"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="incident_severity_1">
<datasetParameter name="start_date">
<datasetParameterExpression><![CDATA[$P{start_date}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="end_date">
<datasetParameterExpression><![CDATA[$P{end_date}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA[$F{SEVERITY}]]></seriesExpression>
<categoryExpression><![CDATA[$F{SEVERITY}]]></categoryExpression>
<valueExpression><![CDATA[$F{SUM(CNT)}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot orientation="Horizontal" labelRotation="0.0"/>
<itemLabel/>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" verticalTickLabels="false" axisLineColor="#000000"/>
</valueAxisFormat>
<rangeAxisMinValueExpression><![CDATA[0]]></rangeAxisMinValueExpression>
<rangeAxisMaxValueExpression><![CDATA[$F{COUNT}]]></rangeAxisMaxValueExpression>
</barPlot>
</barChart>
<barChart>
<chart isShowLegend="false">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="45" width="802" height="113" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="incident_category_1">
<datasetParameter name="start_date">
<datasetParameterExpression><![CDATA[$P{start_date}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="end_date">
<datasetParameterExpression><![CDATA[$P{end_date}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA[$F{CATEGORY}]]></seriesExpression>
<categoryExpression><![CDATA[$F{CATEGORY}]]></categoryExpression>
<valueExpression><![CDATA[$F{COUNT}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot isShowLabels="true" isShowTickLabels="true" isShowTickMarks="true">
<plot orientation="Horizontal" labelRotation="0.0"/>
<itemLabel/>
<rangeAxisMinValueExpression><![CDATA[0]]></rangeAxisMinValueExpression>
<rangeAxisMaxValueExpression><![CDATA[$F{COUNT}]]></rangeAxisMaxValueExpression>
</barPlot>
</barChart>
<staticText>
<reportElement mode="Opaque" x="2" y="0" width="795" height="33" forecolor="#FF0000" backcolor="#00CCCC"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0"/>
<leftPen lineWidth="0.0"/>
<bottomPen lineWidth="0.0"/>
<rightPen lineWidth="0.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="18" isBold="true" pdfFontName="Helvetica-Bold" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[Incident Category ]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="1" y="158" width="795" height="33" forecolor="#FF0000" backcolor="#00CCCC"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0"/>
<leftPen lineWidth="0.0"/>
<bottomPen lineWidth="0.0"/>
<rightPen lineWidth="0.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="18" isBold="true" pdfFontName="Helvetica-Bold" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[Incident Severity]]></text>
</staticText>
</band>
</columnHeader>
<summary>
<band height="507" splitType="Stretch">
<barChart>
<chart isShowLegend="false">
<reportElement x="4" y="43" width="783" height="404"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="Incident_status_1">
<datasetParameter name="start_date">
<datasetParameterExpression><![CDATA[$P{start_date}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="end_date">
<datasetParameterExpression><![CDATA[$P{end_date}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA[$F{STATUS}]]></seriesExpression>
<categoryExpression><![CDATA[$F{STATUS}]]></categoryExpression>
<valueExpression><![CDATA[$F{CNT}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot orientation="Horizontal" labelRotation="0.0"/>
<itemLabel/>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" verticalTickLabels="false" axisLineColor="#000000"/>
</valueAxisFormat>
<rangeAxisMinValueExpression><![CDATA[0]]></rangeAxisMinValueExpression>
<rangeAxisMaxValueExpression><![CDATA[$F{COUNT}]]></rangeAxisMaxValueExpression>
</barPlot>
</barChart>
<staticText>
<reportElement mode="Opaque" x="2" y="0" width="795" height="33" forecolor="#FF0000" backcolor="#00CCCC"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0"/>
<leftPen lineWidth="0.0"/>
<bottomPen lineWidth="0.0"/>
<rightPen lineWidth="0.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="18" isBold="true" pdfFontName="Helvetica-Bold" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[Incident Status]]></text>
</staticText>
<image>
<reportElement x="0" y="457" width="799" height="50"/>
<imageExpression><![CDATA["MSI.png"]]></imageExpression>
</image>
</band>
</summary>
</jasperReport>
现在我将图表视为溢出,我更改了以下属性,
将“位置”设置为“浮动” 将“拉伸类型”设置为“相对于最高的对象” 选中“详细信息溢出时打印”复选框。 但仍然没有帮助。
请协助。
答案 0 :(得分:1)
尝试在您使用的每个isPrintWhenDetailOverflows="true"
标记中放置reportElement
。你只把它放在你的一个标签中
如果乐队不适合当前页面,则元素将在下一页重新打印。