2012-03-05 118 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