简体   繁体   English

iReport中的Jasper报告图重复

[英]Jasper Report graph in iReport repeating

I have a line graph in iReport which is incrementally repeating in every page, that is, if the graph has 30 x/y pairs (this is dynamic), the report will have 30 pages, of which the first will have just one value, the 2nd two values, and so on. 我在iReport中有一个折线图,该折线图在每一页中都不断重复,也就是说,如果该图有30个x / y对(这是动态的),则报表将有30页,其中第一页只有一个值,第二个两个值,依此类推。 Only the last one will contain the complete graph. 只有最后一个将包含完整的图形。

Questions "chart repeat many time" and "Problem with charting using JasperReport" and "How to print the grand total only in the last page of a very long report?" 问题“图表重复很多次”“使用JasperReport进行图表绘制有关的问题”“如何仅在很长的报告的最后一页中打印总计?”的问题。 did not solve my problem. 没有解决我的问题。 I understand that putting the chart in the Detail section makes the chart repeat, but putting it in the Summary, Footer, lastPageFooter, Title, etc. sections makes it display only one value. 我知道将图表放在“详细信息”部分会使图表重复,但是将其放在“摘要”,“页脚”,“ lastPageFooter”,“标题”等部分会使它仅显示一个值。 Same when I put it in the Detail section and use <printWhenExpression> . 将其放在“详细信息”部分中并使用<printWhenExpression>

My code: 我的代码:

<?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>

Datasource here is a JRBeanCollectionDataSource. 这里的数据源是一个JRBeanCollectionDataSource。

Putting it in the Detail band is wrong (as you noticed). 将其放在“详细信息”区域中是错误的(如您所注意到的)。 Putting it in the Title or Summary will work. 将其放在标题或摘要中将起作用。 Your choice of evaluationTime="Page" doesn't look right. 您选择的evaluationTime="Page"看起来不正确。 Try changing this to evaluationTime="Report" 尝试将其更改为evaluationTime="Report"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM