I have a report using JasperReports 5.2.2. This contains embedded charts - a line chart, a bar chart and a multi-axis chart. The line and bar chart both work well, but the multi-axis chart just stays blank, as if it's not receiving its dataset. The report was designed using Jaspersoft Studio. The three datasets are being passed in as parameters, and all contain the exact same data (three JRBeanCollectionDataSources with the same data).
Any idea what I'm doing wrong?
Below is the JRXML file.
<?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="weekly-page1" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c5b0ee6d-2c48-46e5-92f3-22c62ab9ec53">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<subDataset name="Dataset1" uuid="e20e908b-3e00-4dd1-aab2-b194f5a4e4de">
<queryString language="SQL">
<![CDATA[]]>
</queryString>
<field name="code" class="java.lang.String">
<fieldDescription><![CDATA[code]]></fieldDescription>
</field>
<field name="cumulative" class="java.lang.Integer">
<fieldDescription><![CDATA[cumulative]]></fieldDescription>
</field>
<field name="delays" class="java.lang.Integer">
<fieldDescription><![CDATA[delays]]></fieldDescription>
</field>
<field name="description" class="java.lang.String">
<fieldDescription><![CDATA[description]]></fieldDescription>
</field>
<field name="where" class="java.lang.String">
<fieldDescription><![CDATA[where]]></fieldDescription>
</field>
</subDataset>
<parameter name="dsControllableDelays" class="net.sf.jasperreports.engine.JRDataSource"/>
<parameter name="dsControllableDelays2" class="net.sf.jasperreports.engine.JRDataSource"/>
<parameter name="dsControllableDelays3" class="net.sf.jasperreports.engine.JRDataSource"/>
<queryString language="SQL">
<![CDATA[]]>
</queryString>
<field name="code" class="java.lang.String">
<fieldDescription><![CDATA[code]]></fieldDescription>
</field>
<field name="cumulative" class="java.lang.Integer">
<fieldDescription><![CDATA[cumulative]]></fieldDescription>
</field>
<field name="delays" class="java.lang.Integer">
<fieldDescription><![CDATA[delays]]></fieldDescription>
</field>
<field name="description" class="java.lang.String">
<fieldDescription><![CDATA[description]]></fieldDescription>
</field>
<field name="where" class="java.lang.String">
<fieldDescription><![CDATA[where]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="554" splitType="Stretch">
<barChart>
<chart isShowLegend="false" evaluationTime="Report" customizerClass="net.megabyte.app.diva.rpt.WeeklyControllableDelayCustomiser">
<reportElement x="0" y="0" width="390" height="250" uuid="8d6dac50-adea-4b6c-821d-7ef71f22059c"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="Dataset1" uuid="0f49bb55-5e58-47b4-9111-b0f5bd158c82">
<dataSourceExpression><![CDATA[$P{dsControllableDelays}]]></dataSourceExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["SERIES 1"]]></seriesExpression>
<categoryExpression><![CDATA[$F{description}]]></categoryExpression>
<valueExpression><![CDATA[$F{cumulative}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot/>
<itemLabel/>
<categoryAxisFormat>
<axisFormat/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat/>
</valueAxisFormat>
</barPlot>
</barChart>
<lineChart>
<chart evaluationTime="Report">
<reportElement x="390" y="0" width="411" height="250" uuid="e2e7debd-0cb8-4ffc-8ac8-dfb7164a6a6d"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="Dataset1" uuid="8038d4bb-49eb-43da-8bfa-f7b12a46774c">
<dataSourceExpression><![CDATA[$P{dsControllableDelays2}]]></dataSourceExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["SERIES 1"]]></seriesExpression>
<categoryExpression><![CDATA[$F{description}]]></categoryExpression>
<valueExpression><![CDATA[$F{delays}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat/>
</valueAxisFormat>
</linePlot>
</lineChart>
<multiAxisChart>
<chart evaluationTime="Report">
<reportElement x="10" y="260" width="780" height="280" uuid="ccdb8264-2808-4f37-8f1c-f4073ff54b8b"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<multiAxisPlot>
<plot/>
<axis>
<lineChart>
<chart evaluationTime="Report">
<reportElement x="0" y="0" width="0" height="0" backcolor="#FFFFFF" uuid="b7f8198f-a799-415c-b96a-c7e1d3f83872"/>
<chartTitle color="#000000"/>
<chartSubtitle color="#000000"/>
<chartLegend textColor="#000000" backgroundColor="#FFFFFF"/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="Dataset1" uuid="8038d4bb-49eb-43da-8bfa-f7b12a46774c">
<dataSourceExpression><![CDATA[$P{dsControllableDelays3}]]></dataSourceExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["SERIES 1"]]></seriesExpression>
<categoryExpression><![CDATA[$F{description}]]></categoryExpression>
<valueExpression><![CDATA[$F{delays}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat/>
</valueAxisFormat>
</linePlot>
</lineChart>
</axis>
</multiAxisPlot>
</multiAxisChart>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band splitType="Stretch"/>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>
Related
I am trying to access the "Chart Plot" tab of my bar chart in order to change the orientation to horizontal but I'm getting this error with no further details
This error also appears when I click this tab on the other pie chart of the file.
This is the jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.13.0.final using JasperReports Library version 6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05 -->
<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="consumption_template" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c2376118-5b9b-47c0-b7d6-a20b65a05ffb">
<subDataset name="totalKgClothesPieDataSet" uuid="72727fea-d56b-46dd-8104-9ddbf35dad68">
<parameter name="params" class="com.dosiper.laundryserver.laundry.statistics.consumption.dto.export.equipment.pdf.ExportConsumptionPDFParameters"/>
<field name="name" class="java.lang.String"/>
<field name="kgRealPercentage" class="java.lang.Double"/>
</subDataset>
<subDataset name="totalKgClothesBarDataSet" uuid="cc72577b-9c33-4f93-bc5a-0460f7084532">
<parameter name="params" class="com.dosiper.laundryserver.laundry.statistics.consumption.dto.export.equipment.pdf.ExportConsumptionPDFParameters"/>
<field name="name" class="java.lang.String"/>
<field name="kgReal" class="java.lang.Double"/>
</subDataset>
<parameter name="params" class="com.dosiper.laundryserver.laundry.statistics.consumption.dto.export.equipment.pdf.ExportConsumptionPDFParameters"/>
<field name="totalKgClothesPieDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<field name="totalKgClothesBarDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<group name="TotalKgClothes">
<groupHeader>
<band height="552">
<pieChart>
<chart isShowLegend="false" evaluationTime="Report">
<reportElement key="" positionType="Float" isPrintRepeatedValues="false" x="8" y="160" width="540" height="392" uuid="f656a8cf-a3d7-48ee-8128-a7fac530f9ca"/>
<chartTitle>
<font fontName="Arial" size="14" isBold="true"/>
<titleExpression><![CDATA[$P{params}.getTotalKgClothesPieChartTitle()]]></titleExpression>
</chartTitle>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset maxCount="30">
<dataset resetType="Report">
<datasetRun subDataset="totalKgClothesPieDataSet" uuid="e50e959c-3556-430b-97b2-c9bc4ccc10f2">
<datasetParameter name="params">
<datasetParameterExpression><![CDATA[$P{params}]]></datasetParameterExpression>
</datasetParameter>
<dataSourceExpression><![CDATA[$F{totalKgClothesPieDataSource}]]></dataSourceExpression>
</datasetRun>
</dataset>
<keyExpression><![CDATA[$F{name}]]></keyExpression>
<valueExpression><![CDATA[$F{kgRealPercentage}]]></valueExpression>
<labelExpression><![CDATA[$F{name}.toLowerCase()]]></labelExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
</band>
</groupHeader>
</group>
<group name="TotalKgClothesBarChart">
<groupHeader>
<band height="367">
<barChart>
<chart evaluationTime="Report">
<reportElement x="8" y="10" width="542" height="350" uuid="d4072751-ba5d-4c03-8a2d-f2ab02960e59"/>
<chartTitle>
<font fontName="Arial" size="14" isBold="true"/>
<titleExpression><![CDATA[$P{params}.getTotalKgClothesBarChartTitle()]]></titleExpression>
</chartTitle>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset resetType="Report">
<datasetRun subDataset="totalKgClothesBarDataSet" uuid="a763eb3e-b77a-4976-9264-475e19713a73">
<dataSourceExpression><![CDATA[$F{totalKgClothesBarDataSource}]]></dataSourceExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA[$F{name}]]></seriesExpression>
<categoryExpression><![CDATA[$F{name}]]></categoryExpression>
<valueExpression><![CDATA[$F{kgReal}]]></valueExpression>
<labelExpression><![CDATA[$F{name}]]></labelExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot/>
<itemLabel/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</barPlot>
</barChart>
</band>
</groupHeader>
</group>
</jasperReport>
If possible, do you know how to edit the jrxml file to add the "horizontal" orientation manually?
This seems to be something related to version 6.13.0, it works with version "6.12.2" so I just opened an issue in their bug tracker.
Thanks.
I have designed below bar chart in jaspersoft studio, but its not the one what i want. My expected result is given below. Even this may be the basic question, since i am totally new to this report/chart generation work. So it would be much appreciated if someone guide me to get the desired result.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-04-11T10:51:06 -->
<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="dummychart" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6af21e76-9897-424c-935c-909188c48f39">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="QC DB"/>
<queryString>
<![CDATA[select t1.supplier,sum(t2.qty) as received,sum(t2.accepted_qty) as accepted,sum(t2.rejected_qty) as rejected
from qc_master t1
join qc_item_list t2 on t2.i_rep_no = t1.i_rep_no
and t1.cdate between '01-03-2017' and '01-04-2017'
and t2.accepted_qty <> 'null'
and t2.insp_date <> 'null'
group by t1.supplier]]>
</queryString>
<field name="SUPPLIER" class="java.lang.String"/>
<field name="RECEIVED" class="java.math.BigDecimal"/>
<field name="ACCEPTED" class="java.math.BigDecimal"/>
<field name="REJECTED" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<summary>
<band height="399" splitType="Stretch">
<barChart>
<chart evaluationTime="Report">
<reportElement x="0" y="0" width="798" height="399" uuid="4121a817-1fdb-4c0c-81be-2bf388061d09"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[$F{RECEIVED}]]></seriesExpression>
<categoryExpression><![CDATA[$F{SUPPLIER}]]></categoryExpression>
<valueExpression><![CDATA[$F{RECEIVED}]]></valueExpression>
<labelExpression><![CDATA[]]></labelExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA[$F{ACCEPTED}]]></seriesExpression>
<categoryExpression><![CDATA[$F{SUPPLIER}]]></categoryExpression>
<valueExpression><![CDATA[$F{ACCEPTED}]]></valueExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA[$F{REJECTED}]]></seriesExpression>
<categoryExpression><![CDATA[$F{SUPPLIER}]]></categoryExpression>
<valueExpression><![CDATA[$F{REJECTED}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot/>
<itemLabel/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</barPlot>
</barChart>
</band>
</summary>
</jasperReport>
expected one
Try this
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA["Received"]]></seriesExpression>
<categoryExpression><![CDATA[$F{SUPPLIER}]]></categoryExpression>
<valueExpression><![CDATA[$F{RECEIVED}]]></valueExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["Accepted"]]></seriesExpression>
<categoryExpression><![CDATA[$F{SUPPLIER}]]></categoryExpression>
<valueExpression><![CDATA[$F{ACCEPTED}]]></valueExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["Rejected"]]></seriesExpression>
<categoryExpression><![CDATA[$F{SUPPLIER}]]></categoryExpression>
<valueExpression><![CDATA[$F{REJECTED}]]></valueExpression>
</categorySeries>
</categoryDataset>
I am following this tutorial to create my reports using iReport.
I have already created a couple of reports using the guidelines mentioned.
But in a new report, when I set the DataSource of the ListComponent Jasper reports the following error to me:
The method subDataSource(String) is undefined for the type JRDataSource value = ((net.sf.jasperreports.engine.JRDataSource)parameter_REPORT_DATA_SOURCE.getValue()).subDataSource("/items/invoices"); //$JR_EXPR_ID=11$
I tried to look up in the docs, It does mention that JRDataSource doesn't have any such methods. But, I have followed this tutorial earlier and made reports.
This is the JRXML code of the report where I am stuck:
<?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="product-wise-sales-analysis" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a8a1a939-18a1-4ecf-8c4c-9f7b556b5ce3">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<subDataset name="invoices" uuid="9d9c4386-0f01-4f9f-9b17-12906b566f63">
<queryString language="xPath">
<![CDATA[/data/items/invoices]]>
</queryString>
<field name="invoiceId" class="java.lang.String">
<fieldDescription><![CDATA[invoiceId]]></fieldDescription>
</field>
<field name="salesInvoiceDate" class="java.lang.String">
<fieldDescription><![CDATA[salesInvoiceDate]]></fieldDescription>
</field>
<field name="partyName" class="java.lang.String">
<fieldDescription><![CDATA[partyName]]></fieldDescription>
</field>
<field name="quantity" class="java.lang.String">
<fieldDescription><![CDATA[quantity]]></fieldDescription>
</field>
<field name="rate" class="java.lang.String">
<fieldDescription><![CDATA[rate]]></fieldDescription>
</field>
</subDataset>
<queryString language="xPath">
<![CDATA[/data/items]]>
</queryString>
<field name="productCatlgNo" class="java.lang.String">
<fieldDescription><![CDATA[productCatlgNo]]></fieldDescription>
</field>
<field name="description" class="java.lang.String">
<fieldDescription><![CDATA[description]]></fieldDescription>
</field>
<field name="groupName" class="java.lang.String">
<fieldDescription><![CDATA[groupName]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="23" splitType="Stretch">
<staticText>
<reportElement x="0" y="2" width="100" height="20" uuid="b14d57a3-c78e-4121-ac21-955b4ab431f0"/>
<text><![CDATA[productCatlgNo]]></text>
</staticText>
<staticText>
<reportElement x="147" y="2" width="100" height="20" uuid="c009d720-b224-4595-9761-89447d437dc3"/>
<text><![CDATA[description]]></text>
</staticText>
<staticText>
<reportElement x="341" y="0" width="100" height="20" uuid="f22f2f3f-885e-4ffd-bd2f-b69025a46c2d"/>
<text><![CDATA[groupName]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="34" splitType="Stretch">
<textField>
<reportElement x="147" y="0" width="194" height="12" uuid="383b8740-6b4d-4ddd-9e85-6aa45a08c464"/>
<textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="147" height="12" uuid="ebd965f4-5684-49b8-8ed4-e11e43d64230"/>
<textFieldExpression><![CDATA[$F{productCatlgNo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="341" y="0" width="209" height="12" uuid="4b98a152-6c2e-4335-835a-9288c179df5a"/>
<textFieldExpression><![CDATA[$F{groupName}]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="0" y="12" width="555" height="21" uuid="786c54cf-6dc1-4daf-a174-694c24cfd27b"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="invoices" uuid="c61741af-4e58-4bb6-a18b-468a29c02b14">
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}.subDataSource("/items/invoices")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="21" width="555">
<textField>
<reportElement x="5" y="0" width="100" height="20" uuid="c3923524-ac87-4a59-a4d0-89d4c6ade197"/>
<textFieldExpression><![CDATA[$F{invoiceId}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
Any ideas why this is happening?
I figured this out.
For some reason, I had to cast the DataSource of the ListComponent to a JRXmlDataSource object. (I haven't done this casting in my previous reports)
So the expression for DataSource in the ListComponent would be:
((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/items/invoices")
instead of:
$P{REPORT_DATA_SOURCE}).subDataSource("/items/invoices")
In my case, the answer was to select "groovy" as the language used in the report.
Properties -> Report -> Language
I'm using iReport to display a pie chart with 6 different fields. I use 3.1.4 because it is compatible with Bizflow Advreport. When previewing the chart in iReport 3.1.4 the pie chart/legend/titles all show up correctly. But, when I place this on the site it only displays the title. Bringing the file into 5.0.1 nothing shows up, exactly like it does on the website.
I have tried to mess with the margins and the size of the bands, but I cannot seem to get the pie chart to display correctly.
I have also attached the two different previews I receive one from 3.1.4:
and the other from 5.0.1:
Also here is the jrxml file:
<?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="report name" pageWidth="380" pageHeight="300" columnWidth="380" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<queryString>
<![CDATA[Select CapabilityAreaName , SUM(ProjectedDevelopmentCost) as TotalProjectedDevelopmentCost, ROUND(100*SUM(ProjectedDevelopmentCost)/(SELECT SUM(ProjectedDevelopmentCost) FROM RequirementFunding),2)AS percentOfTotal
FROM Requirement
INNER JOIN CapabilityArea
ON Requirement.CapabilityAreaId = CapabilityArea.CapabilityAreaId
INNER JOIN RequirementFunding
ON Requirement.RequirementId = RequirementFunding.RequirementId
GROUP BY CapabilityAreaName]]>
</queryString>
<field name="CapabilityAreaName" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="TotalProjectedDevelopmentCost" class="java.lang.Double">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="percentOfTotal" class="java.lang.Double">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<background>
<band/>
</background>
<title>
<band height="50">
<staticText>
<reportElement x="0" y="12" width="380" height="25"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Project Development Cost By Capability Area]]></text>
</staticText>
<line>
<reportElement x="0" y="49" width="380" height="1"/>
</line>
<line>
<reportElement x="0" y="0" width="380" height="1"/>
</line>
</band>
</title>
<columnHeader>
<band height="250">
<pieChart>
<chart hyperlinkType="Reference">
<reportElement x="0" y="0" width="380" height="250"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<keyExpression><![CDATA[$F{CapabilityAreaName}]]></keyExpression>
<valueExpression><![CDATA[$F{TotalProjectedDevelopmentCost}]]></valueExpression>
<labelExpression><![CDATA[$F{percentOfTotal}.toString() + "% - $" + $F{TotalProjectedDevelopmentCost}]]></labelExpression>
<sectionHyperlink hyperlinkType="Reference">
<hyperlinkReferenceExpression><![CDATA["http://ess-bizflow:8080/bizflowadvreport/flow.html?_flowId=reportTinkerViewReportFlow&reportUnit=/reports/standard_reports/IR_D/AMOD/ActiveRequirementsCostTimeBreakdownTable&&CASelected=" + $F{CapabilityAreaName}]]></hyperlinkReferenceExpression>
</sectionHyperlink>
</pieDataset>
<piePlot>
<plot/>
</piePlot>
</pieChart>
</band>
</columnHeader>
</jasperReport>
Does anyone know what could be causing this issue. I can provide files if that is needed as well.
It seems from XML you have put pie chart in <columnhearder> band try to put the chart in <summary> band.
<columnHeader>
<band height="250">
<pieChart>
<chart hyperlinkType="Reference">
<reportElement x="0" y="0" width="380" height="250"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<keyExpression><![CDATA[$F{CapabilityAreaName}]]></keyExpression>
<valueExpression><![CDATA[$F{TotalProjectedDevelopmentCost}]]></valueExpression>
<labelExpression><![CDATA[$F{percentOfTotal}.toString() + "% - $" + $F{TotalProjectedDevelopmentCost}]]></labelExpression>
<sectionHyperlink hyperlinkType="Reference">
<hyperlinkReferenceExpression><![CDATA["http://ess-bizflow:8080/bizflowadvreport/flow.html?_flowId=reportTinkerViewReportFlow&reportUnit=/reports/standard_reports/IR_D/AMOD/ActiveRequirementsCostTimeBreakdownTable&&CASelected=" + $F{CapabilityAreaName}]]></hyperlinkReferenceExpression>
</sectionHyperlink>
</pieDataset>
<piePlot>
<plot/>
</piePlot>
</pieChart>
</band>
</columnHeader>
Try this:-
<?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="report name" pageWidth="380" pageHeight="300" columnWidth="380" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
<![CDATA[Select CapabilityAreaName , SUM(ProjectedDevelopmentCost) as
TotalProjectedDevelopmentCost,
ROUND(100*SUM(ProjectedDevelopmentCost)/(SELECT
SUM(ProjectedDevelopmentCost) FROM RequirementFunding),2)AS percentOfTotal
FROM Requirement
INNER JOIN CapabilityArea
ON Requirement.CapabilityAreaId = CapabilityArea.CapabilityAreaI d
INNER JOIN RequirementFunding
ON Requirement.RequirementId = RequirementFunding.RequirementId
GROUP BY CapabilityAreaName]]>
</queryString>
<field name="CapabilityAreaName" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="TotalProjectedDevelopmentCost" class="java.lang.Double">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="percentOfTotal" class="java.lang.Double">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<background>
<band/>
</background>
<title>
<band height="50">
<staticText>
<reportElement x="0" y="12" width="380" height="25"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Project Development Cost By Capability Area]]></text>
</staticText>
<line>
<reportElement x="0" y="49" width="380" height="1"/>
</line>
<line>
<reportElement x="0" y="0" width="380" height="1"/>
</line>
</band>
</title>
<summary>
<band height="300">
<pieChart>
<chart hyperlinkType="Reference">
<reportElement x="14" y="15" width="348" height="270"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<keyExpression><![CDATA[$F{CapabilityAreaName}]]></keyExpression>
<valueExpression><![CDATA[$F{TotalProjectedDevelopmentCost}]]></valueExpression>
<labelExpression><![CDATA[$F{percentOfTotal}.toString() + "% - $" + $F{TotalProjectedDevelopmentCost}]]></labelExpression>
<sectionHyperlink hyperlinkType="Reference">
<hyperlinkReferenceExpression><![CDATA["http://ess-bizflow:8080/bizflowadvreport/flow.html?_flowId=reportTinkerViewReportFlow&reportUnit=/reports/standard_reports/IR_D/AMOD/ActiveRequirementsCostTimeBreakdownTable&&CASelected=" + $F{CapabilityAreaName}]]></hyperlinkReferenceExpression>
</sectionHyperlink>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
</band>
</summary>
I have generated a report (with JasperReport). My problem that the chart repeats, I have one chart and the report contains 22 pages! What is the problem?
This is my report:
<?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="report2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" 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"/>
<subDataset name="New Dataset 1">
<parameter name="SQL" class="java.lang.String"/>
<parameter name="Titre" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[$P!{SQL}]]>
</queryString>
<field name="nb" class="java.lang.Long"/>
<field name="champ1" class="java.lang.String"/>
<field name="champ2" class="java.lang.String"/>
</subDataset>
<parameter name="SQL" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="Titre" class="java.lang.String"/>
<queryString>
<![CDATA[select id from jiraissue]]>
</queryString>
<field name="id" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="46" splitType="Stretch">
<textField>
<reportElement x="89" y="15" width="180" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$P{Titre}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="13" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="185" splitType="Stretch">
<stackedBar3DChart>
<chart>
<reportElement x="57" y="16" width="420" height="165"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="New Dataset 1">
<datasetParameter name="SQL">
<datasetParameterExpression><![CDATA[$P{SQL}]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA[$F{champ2}]]></seriesExpression>
<categoryExpression><![CDATA[$F{champ1}]]></categoryExpression>
<valueExpression><![CDATA[$F{nb}]]></valueExpression>
</categorySeries>
</categoryDataset>
<bar3DPlot>
<plot/>
<itemLabel color="#000000" backgroundColor="#FFFFFF"/>
<categoryAxisFormat>
<axisFormat>
<labelFont/>
<tickLabelFont/>
</axisFormat>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat>
<labelFont/>
<tickLabelFont/>
</axisFormat>
</valueAxisFormat>
</bar3DPlot>
</stackedBar3DChart>
</band>
</detail>
<columnFooter>
<band height="24" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="20" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="22" splitType="Stretch"/>
</summary>
Update
I have solved the problem by moving the chart to the summary part :)
In Jasper Report, everything you place in the detail band is repeated number of times it appears in the source.
If you want to show anything (not only chart) just once, avoid the detail band.
For example, you can place it in the summary section.
Update: As others pointed, I have extended my answer a little bit.
I also had face with the same problem like this before. It is because your data will be looped which causes such redundant of data. What you need to do is go to 'Print when expression' in properties and set your variable report count to 1. This is how it looks, $V{REPORT_COUNT}==1. It will display only once in your report.
I use $V{PAGE_NUMBER} == 1 as value of 'Print when expression' so it is forced to appear only on first page.