2012-03-05 76 views
2

我在iReport中有一个线条图,它在每个页面中递增地重复,也就是说,如果图形有30个x/y对(这是动态的),报告将有30页第一个将只有一个值,第二个两个值,等等。只有最后一个将包含完整的图表。iReport中的Jasper Report图形重复

问题"chart repeat many time""Problem with charting using JasperReport""How to print the grand total only in the last page of a very long report?"确实不是解决我的问题。我知道将图表放在Detail部分会使图表重复,但将它放在Summary,Footer,lastPageFooter,Title等部分中会使其仅显示一个值。同样,当我把它放在细节部分,并使用<printWhenExpression>

我的代码:

<?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="nodes-allarmipersistenti" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> 
    <property name="ireport.zoom" value="1.0"/> 
    <property name="ireport.x" value="0"/> 
    <property name="ireport.y" value="0"/> 
    <field name="day" class="java.lang.Number"/> 
    <field name="month" class="java.lang.String"/> 
    <field name="year" class="java.lang.String"/> 
    <field name="dsunita" class="java.lang.String"/> 
    <field name="valueNumber" class="java.lang.Number"/> 
    <field name="logo" class="java.lang.String"/> 
    <field name="today" class="java.lang.String"/> 
    <field name="option" class="java.lang.String"/> 
    <title> 
     <band height="89"> 
      <staticText> 
       <reportElement mode="Opaque" x="0" y="67" width="424" height="22" backcolor="#CCFFFF"/> 
       <textElement textAlignment="Right" verticalAlignment="Middle" markup="none"> 
        <font size="10" isBold="true" pdfFontName="Helvetica-Bold" isPdfEmbedded="true"/> 
       </textElement> 
       <text><![CDATA[GRAFICO PARAMETRO]]></text> 
      </staticText> 
      <staticText> 
       <reportElement x="600" y="0" width="100" height="38"/> 
       <textElement verticalAlignment="Middle"/> 
       <text><![CDATA[Stampato in data]]></text> 
      </staticText> 
      <textField> 
       <reportElement x="700" y="0" width="102" height="38"/> 
       <textElement textAlignment="Right" verticalAlignment="Middle"/> 
       <textFieldExpression><![CDATA[$F{today}]]></textFieldExpression> 
      </textField> 
      <image> 
       <reportElement x="0" y="0" width="100" height="67"/> 
       <imageExpression><![CDATA[$F{logo}]]></imageExpression> 
      </image> 
      <staticText> 
       <reportElement x="700" y="38" width="102" height="29"/> 
       <textElement textAlignment="Right"/> 
       <text><![CDATA[MaRe - Telecontrollo]]></text> 
      </staticText> 
      <textField> 
       <reportElement mode="Opaque" x="424" y="67" width="378" height="22" backcolor="#CCFFFF"/> 
       <textElement verticalAlignment="Middle"/> 
       <textFieldExpression><![CDATA[' ' + $F{option}]]></textFieldExpression> 
      </textField> 
     </band> 
    </title> 
    <lastPageFooter> 
     <band height="387" splitType="Stretch"> 
      <xyLineChart> 
       <chart evaluationTime="Page"> 
        <reportElement x="0" y="0" width="802" height="387"/> 
        <chartTitle/> 
        <chartSubtitle/> 
        <chartLegend/> 
       </chart> 
       <xyDataset> 
        <dataset incrementType="Report"/> 
        <xySeries> 
         <seriesExpression><![CDATA["Unità " + $F{dsunita}]]></seriesExpression> 
         <xValueExpression><![CDATA[$F{day}]]></xValueExpression> 
         <yValueExpression><![CDATA[$F{valueNumber}]]></yValueExpression> 
        </xySeries> 
       </xyDataset> 
       <linePlot> 
        <plot/> 
       </linePlot> 
      </xyLineChart> 
     </band> 
    </lastPageFooter> 
</jasperReport> 

数据源这里是一个JRBeanCollectionDataSource。

回答

4

把它放在细节带是错误的(正如你注意到的)。将它放在标题或摘要中即可使用。您选择的evaluationTime="Page"看起来不正确。尝试改变这个evaluationTime="Report"

+0

工作正常,谢谢,我发现了几个小时后发布的问题,但现在回答我自己的,然后我只是忘了为时尚早。无论如何都是为了将​​来的参考。 – Alessandro 2012-03-09 10:52:03