jaspersoft studio - bar chart category issue - jasper-reports

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>

Related

Got NullPointerException during editing chart plot at Jaspersoft Studio

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.

Jasper: horizontal main report causes the error "Subreport overflow on a band that does not support overflow"

I've created a report, that you can find here:
Jasper, 'print when' create white space,
StackOverflowExample.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="StackOverflowExample" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="749cd048-9a0d-4a00-89bf-1a75a4565943">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<queryString>
<![CDATA[SELECT "ORDERS"."SHIPCOUNTRY",
Max("ORDERS"."SHIPCOUNTRY")
FROM "ORDERS"
GROUP BY "ORDERS"."SHIPCOUNTRY"
ORDER BY "ORDERS"."SHIPCOUNTRY" ASC]]>
</queryString>
<field name="SHIPCOUNTRY" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="SHIPCOUNTRY"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<field name="C2" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="C2"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="170">
<subreport>
<reportElement x="-20" y="50" width="297" height="120" isRemoveLineWhenBlank="true" uuid="4b89b974-f838-4bb7-85b6-1b0f1079c1e6">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<subreportParameter name="country">
<subreportParameterExpression><![CDATA[$F{SHIPCOUNTRY}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["StackOverflowExampleSubReport.jasper"]]></subreportExpression>
</subreport>
<textField>
<reportElement x="43" y="0" width="185" height="50" uuid="0c170024-70ea-492f-95fe-99ff3a27cb6d"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="19"/>
</textElement>
<textFieldExpression><![CDATA[$F{SHIPCOUNTRY}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
StackOverflowExampleSubReport.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="StackOverflowExample" columnCount="2" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="749cd048-9a0d-4a00-89bf-1a75a4565943">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<parameter name="country" class="java.lang.String">
<defaultValueExpression><![CDATA["France"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT "ORDERS"."ORDERDATE",
"ORDERS"."FREIGHT"
FROM "ORDERS"
WHERE "ORDERS"."SHIPCOUNTRY" = $P{country}]]>
</queryString>
<field name="ORDERDATE" class="java.sql.Timestamp">
<property name="com.jaspersoft.studio.field.label" value="ORDERDATE"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<field name="FREIGHT" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="FREIGHT"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="130">
<printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()==1)]]></printWhenExpression>
<lineChart>
<chart evaluationTime="Report">
<reportElement isPrintRepeatedValues="false" x="0" y="3" width="235" height="125" isRemoveLineWhenBlank="true" uuid="3b5f7d89-490b-468f-9112-f606f4eda437"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[$P{country}]]></seriesExpression>
<categoryExpression><![CDATA[$F{ORDERDATE}]]></categoryExpression>
<valueExpression><![CDATA[$F{FREIGHT}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</linePlot>
</lineChart>
</band>
</detail>
</jasperReport>
This report works, what I have is this
https://community.jaspersoft.com/sites/default/files/user_uploads/ho.hince/capture_report_test.png
The problem :
The order is vertical. What we can see is Argentina, Brazil, Austria, Canada, etc.. But I want to have Argentina, Austria, Belgium, Brazil, etc..
If I change the print order to horizontal, I get the error :
Subreport overflowed on a band that does not support overflow.
The answer Subreport overflowed on a band that does not support overflow tells that I have to use vertical, but I want it horizontal.
How can I solve it? Any ideas or tricks?
The detail band in horizontal reports is not allowed to stretch vertically, so you need to make it tall enough to fit the subreport.
In your report, the subreport element in the master report has height=120. But the subreport has detail band with height=130, plus 20 pixels top margin and 20 bottom margin. So the subreport actually takes 170 pixels in height.
If you set the height of the subreport element in the master report to 170 and the height of the master detail band to 220, it will work with horizontal print order.

Jasper, 'print when' create white space,

I've created a simple JasperReport example, using the sample DB:
StackOverflowExample.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="StackOverflowExample" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="749cd048-9a0d-4a00-89bf-1a75a4565943">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<queryString>
<![CDATA[SELECT DISTINCT "ORDERS"."SHIPCOUNTRY"
FROM "ORDERS"]]>
</queryString>
<field name="SHIPCOUNTRY" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="SHIPCOUNTRY"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="183">
<subreport>
<reportElement x="0" y="0" width="556" height="170" isRemoveLineWhenBlank="true" uuid="4b89b974-f838-4bb7-85b6-1b0f1079c1e6"/>
<subreportParameter name="country">
<subreportParameterExpression><![CDATA[$F{SHIPCOUNTRY}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["StackOverflowExampleSubReport.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
StackOverflowExampleSubReport.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="StackOverflowExample" columnCount="2" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="749cd048-9a0d-4a00-89bf-1a75a4565943">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<parameter name="country" class="java.lang.String">
<defaultValueExpression><![CDATA["France"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT "ORDERS"."ORDERDATE",
"ORDERS"."FREIGHT"
FROM "ORDERS"
WHERE "ORDERS"."SHIPCOUNTRY" = $P{country}]]>
</queryString>
<field name="ORDERDATE" class="java.sql.Timestamp">
<property name="com.jaspersoft.studio.field.label" value="ORDERDATE"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<field name="FREIGHT" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="FREIGHT"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="160">
<lineChart>
<chart evaluationTime="Report">
<reportElement x="15" y="5" width="255" height="155" isRemoveLineWhenBlank="true" uuid="3b5f7d89-490b-468f-9112-f606f4eda437">
<printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()==1)]]></printWhenExpression>
</reportElement>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[$P{country}]]></seriesExpression>
<categoryExpression><![CDATA[$F{ORDERDATE}]]></categoryExpression>
<valueExpression><![CDATA[$F{FREIGHT}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</linePlot>
</lineChart>
</band>
</detail>
</jasperReport>
The problem is that I have a lot of empty useless space
Subreport
An image of the subreport, with the parameter country set to "France", it contains the first page as below and 7 other empty pages
https://community.jaspersoft.com/sites/default/files/user_uploads/ho.hince/capture.png
MainReport
For the main report, the first two page as below, there is a total of 93 pages, most of them which are empty:
https://community.jaspersoft.com/sites/default/files/user_uploads/ho.hince/capture_0.png
https://community.jaspersoft.com/sites/default/files/user_uploads/ho.hince/capture_1.png
The reason for the white space is that I print the chart in the subreport report once. I do it with the property printWhen.
printWhen => new Boolean($V{REPORT_COUNT}.intValue()==1)
I can't move the chart out of the Detail band, because I've set the subreport properties with Column Count = 2 and Print Order = Horizontal. I did that, cause I wish to have the charts in two column just like that:
https://community.jaspersoft.com/sites/default/files/user_uploads/ho.hince/capture_2.png
(The problem here is that the chart are duplicated)
I found the solution, I was printing the chart only once, but I was printing the Detail band each time, so I had to move the print when expression to the Detail band.
<band height="160">
<printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()==1)]]></printWhenExpression>
The main chart must have two column in vertical order, and the subreport 2 column in horizontal order.
EDIT
You can also change the main report properties :Print Order ==> vertical and Column Count ==> 2
StackOverflowExample.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="StackOverflowExample" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="749cd048-9a0d-4a00-89bf-1a75a4565943">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<queryString>
<![CDATA[SELECT "ORDERS"."SHIPCOUNTRY",
Max("ORDERS"."SHIPCOUNTRY")
FROM "ORDERS"
GROUP BY "ORDERS"."SHIPCOUNTRY"
ORDER BY "ORDERS"."SHIPCOUNTRY" ASC]]>
</queryString>
<field name="SHIPCOUNTRY" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="SHIPCOUNTRY"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<field name="C2" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="C2"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="170">
<subreport>
<reportElement x="-20" y="50" width="297" height="120" isRemoveLineWhenBlank="true" uuid="4b89b974-f838-4bb7-85b6-1b0f1079c1e6">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<subreportParameter name="country">
<subreportParameterExpression><![CDATA[$F{SHIPCOUNTRY}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["StackOverflowExampleSubReport.jasper"]]></subreportExpression>
</subreport>
<textField>
<reportElement x="43" y="0" width="185" height="50" uuid="0c170024-70ea-492f-95fe-99ff3a27cb6d"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="19"/>
</textElement>
<textFieldExpression><![CDATA[$F{SHIPCOUNTRY}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
StackOverflowExampleSubReport.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="StackOverflowExample" columnCount="2" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="749cd048-9a0d-4a00-89bf-1a75a4565943">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<parameter name="country" class="java.lang.String">
<defaultValueExpression><![CDATA["France"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT "ORDERS"."ORDERDATE",
"ORDERS"."FREIGHT"
FROM "ORDERS"
WHERE "ORDERS"."SHIPCOUNTRY" = $P{country}]]>
</queryString>
<field name="ORDERDATE" class="java.sql.Timestamp">
<property name="com.jaspersoft.studio.field.label" value="ORDERDATE"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<field name="FREIGHT" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="FREIGHT"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="130">
<printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()==1)]]></printWhenExpression>
<lineChart>
<chart evaluationTime="Report">
<reportElement isPrintRepeatedValues="false" x="0" y="3" width="235" height="125" isRemoveLineWhenBlank="true" uuid="3b5f7d89-490b-468f-9112-f606f4eda437"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[$P{country}]]></seriesExpression>
<categoryExpression><![CDATA[$F{ORDERDATE}]]></categoryExpression>
<valueExpression><![CDATA[$F{FREIGHT}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</linePlot>
</lineChart>
</band>
</detail>
</jasperReport>

Why is piechart in subreport is not displayed?

With the help of iReport 5.6.0 tool, I have created a master report. Then I have drag and drop a subreport to the repot group band of the master report. I have defined the SQL query and set the key and value via wizard. After that I have added a pie chart to the subreport.
When I run the subreport individually, it works fine with the provided SQL query. But when I run the master report via DynamicReports with Java code, it seems that the query does not work and return null values. As a result, no chart is displayed.
Is there any missing steps in my approach? Do I need to map/link somehow the subreport query results to master report?
Master report jrxml:
<?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="templatedesign2" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="575" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" uuid="8c9654e9-6770-46c4-a4d0-4bdf99195b70">
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\DynamicReports\\src\\subreport\\"]]></defaultValueExpression>
</parameter>
<field name="item" class="java.lang.String"/>
<field name="reportTitle" class="java.lang.String"/>
<field name="customerName" class="java.lang.String"/>
<group name="Intro">
<groupHeader>
<band height="255">
<subreport isUsingCache="false">
<reportElement x="0" y="160" width="575" height="77" uuid="eb90e8b6-2860-4c94-ad10-3eb5031502fc"/>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "templatereport2_subreport3.jasper"]]></subreportExpression>
</subreport>
</band>
</groupHeader>
</group>
</jasperReport>
subreport jrxml:
<?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="templatereport2_subreport3" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isTitleNewPage="true" uuid="3dc0ebf2-660d-4d0c-af85-ccae1f01bdee">
<parameter name="runCycleId" class="java.lang.String"/>
<queryString>
<![CDATA[SELECT
count(status) AS count,
case when status=TRUE then 'Succeeded'else 'Failed'end AS status
FROM
"dbtable" dbtable
WHERE
id = 157
GROUP BY
status]]>
</queryString>
<field name="count" class="java.lang.Long"/>
<field name="status" class="java.lang.String"/>
<title>
<band height="351" splitType="Stretch">
<pie3DChart>
<chart evaluationTime="Report">
<reportElement x="20" y="22" width="415" height="244" uuid="a43afa44-c4e5-4ad5-b06e-8922128bcdaf"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<keyExpression><![CDATA[$F{status}]]></keyExpression>
<valueExpression><![CDATA[$F{count}]]></valueExpression>
</pieDataset>
<pie3DPlot>
<plot/>
<itemLabel/>
</pie3DPlot>
</pie3DChart>
<textField>
<reportElement x="134" y="292" width="100" height="20" uuid="2726affe-1fef-45a1-abc8-8da8c9856e42"/>
<textFieldExpression><![CDATA[$F{count}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="20" y="292" width="100" height="20" uuid="fa4e41c0-b4f4-443c-ab9e-3cf048a3f520"/>
<textFieldExpression><![CDATA[$F{status}]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
Can you please advise?
Since you are using a query in the subreport you should pass the connection, not the datasource to it.
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
In your example
<subreport isUsingCache="false">
reportElement x="0" y="160" width="575" height="77" uuid="eb90e8b6-2860-4c94-ad10-3eb5031502fc"/>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "templatereport2_subreport3.jasper"]]></subreportExpression>
</subreport>

JasperReports + MultiAxisChart - chart stays blank

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>