Reputation: 7532
I'm working with Jaspersoft Studio 5.6, trying to create a report that shows multiple XY (or bar) charts based upon a grouping parameter. I've dumbed down my original data to the following, and I still can't figure it out.
DATA
+------+------+-------+
| xrow | yrow | group |
+------+------+-------+
| 1 | 11 | 1 |
| 2 | 12 | 1 |
| 3 | 10 | 1 |
| 1 | 5 | 2 |
| 2 | 10 | 2 |
| 3 | 14 | 2 |
+------+------+-------+
Here is my XML code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version last-->
<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="group3" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="cdd6d2cf-7c0c-4d79-8cfe-a4f1e04da233">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Office"/>
<queryString language="SQL">
<![CDATA[SELECT maintenance.test.xrow,
maintenance.test.yrow,
maintenance.test.group
FROM maintenance.test]]>
</queryString>
<field name="xrow" class="java.lang.Integer">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="yrow" class="java.lang.Integer">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="group" class="java.lang.Integer">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<sortField name="group"/>
<sortField name="xrow"/>
<group name="Group1">
<groupExpression><![CDATA[$F{group}]]></groupExpression>
<groupHeader>
<band height="190">
<barChart>
<chart evaluationTime="Report">
<reportElement x="40" y="0" width="460" height="190" uuid="582be7ed-4b48-4d55-a2b6-1295290d34e3"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset resetType="Group" resetGroup="Group1"/>
<categorySeries>
<seriesExpression><![CDATA["SERIES 1"]]></seriesExpression>
<categoryExpression><![CDATA[$F{xrow}]]></categoryExpression>
<valueExpression><![CDATA[$F{yrow}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot/>
<itemLabel/>
<categoryAxisFormat>
<axisFormat/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat/>
</valueAxisFormat>
</barPlot>
</barChart>
</band>
</groupHeader>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
</jasperReport>
I've created a report group for the column "group"
I'm putting the chart in the Group header band. and I've tried setting "reset on" to GROUP, as well as REPORT (in chart wizard) with no change in results. See below screen shot.
I'm at a loss of what to try next.
Upvotes: 1
Views: 3209
Reputation: 7532
I took a closer look at the chart properties, and noticed there was a parameter called Evaluation Time, Changed it from "Report" to the name of the group. Alternatively change the following..
<chart evaluationTime="Report">
to
<chart evaluationTime="Group" evaluationGroup="group">
With the chart in the group header\footer, this will allow the chart to only show the current group data.
Upvotes: 2