Jump to content
We've recently updated our Privacy Statement, available here ×

chart draw repeating


samp7673

Recommended Posts

So I have a fairly simple bar chart. I create a query to get the 2 different series. The chart foes in the detail band. The bars on the chart seem to come up good enough and the legend is fine but, the chart itself gets repeated 2 extra times. I thought may be it was because I was using fields in the column band and not parameters but that did not resolve the problem. Is it coming from a default group by setting and extra charts are just a part of that?

 

Mike

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

 

You should post the JRXML here so we understand what you are doing.

But I would ask you why you put the chart in the detail band if you want it to appear only once?

If you put it in the detail, it would appear once for each record in the data source. Is that what you want?

 

Thank you,

Teodor

 

Link to comment
Share on other sites

So here it is:

<?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="assessment_report" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30">
    <field name="subtopic" class="java.lang.String"/>
    <field name="lastname" class="java.lang.String"/>
    <field name="score" class="java.lang.Double"/>
    <field name="goal" class="java.lang.Double"/>
    <field name="grade" class="java.lang.Integer"/>
    <field name="subject" class="java.lang.String"/>
    <field name="topic" class="java.lang.String"/>
    <field name="id" class="java.lang.Integer"/>
    <background>
        <band/>
    </background>
    <title>
        <band height="84">
            <line>
                <reportElement x="0" y="8" width="555" height="1"/>
            </line>
            <line>
                <reportElement positionType="FixRelativeToBottom" x="0" y="51" width="555" height="1"/>
            </line>
            <staticText>
                <reportElement x="1" y="9" width="424" height="35" forecolor="#0066CC"/>
                <textElement textAlignment="Left">
                    <font size="26" isBold="true"/>
                </textElement>
                <text><![CDATA[Assessment Report]]></text>
            </staticText>
            <textField>
                <reportElement x="46" y="52" width="70" height="20"/>
                <textElement/>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{lastname}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="232" y="51" width="35" height="20"/>
                <textElement/>
                <text><![CDATA[Grade]]></text>
            </staticText>
            <textField>
                <reportElement x="267" y="51" width="49" height="20"/>
                <textElement/>
                <textFieldExpression class="java.lang.Integer"><![CDATA[$F{grade}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="316" y="51" width="40" height="20"/>
                <textElement/>
                <text><![CDATA[subject]]></text>
            </staticText>
            <textField>
                <reportElement x="356" y="51" width="57" height="20"/>
                <textElement/>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{subject}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <pageHeader>
        <band/>
    </pageHeader>
    <columnHeader>
        <band height="50">
            <staticText>
                <reportElement x="1" y="-32" width="45" height="20"/>
                <textElement/>
                <text><![CDATA[student:]]></text>
            </staticText>
            <textField>
                <reportElement x="1" y="0" width="186" height="20"/>
                <textElement/>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{topic}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="213" isSplitAllowed="false">
            <barChart>
                <chart>
                    <reportElement x="1" y="0" width="424" height="213"/>
                    <chartTitle/>
                    <chartSubtitle/>
                    <chartLegend position="Right"/>
                </chart>
                <categoryDataset>
                    <categorySeries>
                        <seriesExpression><![CDATA["Student's Current Score"]]></seriesExpression>
                        <categoryExpression><![CDATA[$F{subtopic}]]></categoryExpression>
                        <valueExpression><![CDATA[$F{score}]]></valueExpression>
                        <labelExpression><![CDATA["Student's Current Score"]]></labelExpression>
                        <itemHyperlink/>
                    </categorySeries>
                    <categorySeries>
                        <seriesExpression><![CDATA["Program Goal"]]></seriesExpression>
                        <categoryExpression><![CDATA[$F{subtopic}]]></categoryExpression>
                        <valueExpression><![CDATA[$F{goal}]]></valueExpression>
                        <labelExpression><![CDATA["Program Goal"]]></labelExpression>
                        <itemHyperlink/>
                    </categorySeries>
                </categoryDataset>
                <barPlot>
                    <plot>
                        <seriesColor seriesOrder="0" color="#33FF33"/>
                        <seriesColor seriesOrder="1" color="#6666FF"/>
                    </plot>
                    <categoryAxisFormat>
                        <axisFormat>
                            <labelFont/>
                            <tickLabelFont/>
                        </axisFormat>
                    </categoryAxisFormat>
                    <valueAxisFormat>
                        <axisFormat>
                            <labelFont/>
                            <tickLabelFont/>
                        </axisFormat>
                    </valueAxisFormat>
                </barPlot>
            </barChart>
        </band>
    </detail>
    <columnFooter>
        <band/>
    </columnFooter>
    <pageFooter>
        <band height="38">
            <textField evaluationTime="Report" pattern="" isBlankWhenNull="false">
                <reportElement key="textField" x="516" y="6" width="36" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
                <box>
                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement>
                    <font size="10"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="false">
                <reportElement key="textField" x="342" y="6" width="170" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
                <box>
                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right">
                    <font size="10"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="false">
                <reportElement key="textField" x="1" y="6" width="209" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
                <box>
                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement>
                    <font size="10"/>
                </textElement>
                <textFieldExpression class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
    <summary>
        <band/>
    </summary>
</jasperReport>
 

The 2 chart examples I had scene, both had charts in the detail band so I has assumed that was ok but may be I missed something.

 

Mike

 

Link to comment
Share on other sites

Hi,

 

I still don't understand what kind of data you are providing to the report. How many records in the data source and why you did not use parameters, if you have single values.

 

But move the chart element to the <summary> section and see if it works like you expected.

Having the chart in the detail makes no sense whatsoever and I don't know what samples you've seen.

It is always better to check the samples shipped with JR, under the /demo/samples/charts folder of the project package.

 

I hope this helps.
Teodor

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...