jaspersoft studio - 条形图类别问题

时间:2017-04-11 05:46:19

标签: jasper-reports bar-chart

我在jaspersoft工作室设计了下面的条形图,但它不是我想要的那个。我的预期结果如下。即使这可能是基本问题,因为我对这份报告/图表生成工作完全不熟悉。因此,如果有人指导我获得所需的结果,我将不胜感激。

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

enter image description here

预计一个 enter image description here

1 个答案:

答案 0 :(得分:1)

试试这个

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