我能够使用链接:create MultiAxis Chart with Jasper report开始使用Jasper报告的MultiAxis Chart。
我也可以创建图表但不完全格式化。我有Axis问题。两个X轴都在左侧。如何在右侧移动一个条形图轴。以下是我当前问题的图片:
以下是我的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="cutting_indicator_cutter" 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="48"/>
<subDataset name="chart1">
<queryString language="SQL">
<![CDATA[select Q.proddate,NVL(Q.m2NetReel,0)
,case when Q.HMO <> 0 then
NVL((Q.m2NetReel/Q.HMO),0)
end as m2NETBYHMO,
Q.Objectif_HMOBY1000
from (
SELECT
PROD_DATE as proddate,
case when CUTTING_PRODUCTIVITY.REMAKE_CUT_SQM is null then CUTTING_PRODUCTIVITY.CUTTER_NET_SQM
else
CUTTING_PRODUCTIVITY.CUTTER_NET_SQM + CUTTING_PRODUCTIVITY.REMAKE_CUT_SQM
end as m2NetReel,
(CUTTING_PRODUCTIVITY.MACHINE_WORKING_HOURS_NORM * CUTTING_PRODUCTIVITY.USER_QUANTITY ) as HMO,
1000/(CUTTING_MACHINE.CADENCY*19.26) as Objectif_HMOBY1000
FROM CUTTING_PRODUCTIVITY CUTTING_PRODUCTIVITY
INNER JOIN CUTTING_MACHINE CUTTING_MACHINE
ON CUTTING_MACHINE_ID=CUTTING_MACHINE.CUTTING_ID where trunc(CUTTING_PRODUCTIVITY.PROD_DATE) >= '1-May-15' and trunc( CUTTING_PRODUCTIVITY.PROD_DATE ) <='31-May-15'
ORDER BY CUTTER) Q]]>
</queryString>
<field name="PRODDATE" class="java.sql.Timestamp"/>
<field name="NVL(Q.M2NETREEL,0)" class="java.math.BigDecimal"/>
<field name="M2NETBYHMO" class="java.math.BigDecimal"/>
<field name="OBJECTIF_HMOBY1000" class="java.math.BigDecimal"/>
</subDataset>
<queryString>
<![CDATA[SELECT EST_CUTTER_GLASSES_QTY,
CUTTER_NET_SQM,
REMAKE_CUT_QTY,
PROD_DATE,
REMAKE_CUT_SQM,
CUTTING_MACHINE.CADENCY,
USER_QUANTITY,
CUTTER,
MACHINE_WORKING_HOURS_NORM
FROM CUTTING_PRODUCTIVITY CUTTING_PRODUCTIVITY
INNER JOIN CUTTING_MACHINE CUTTING_MACHINE
ON CUTTING_MACHINE_ID=CUTTING_MACHINE.CUTTING_ID
where trunc(CUTTING_PRODUCTIVITY.PROD_DATE) >= '1-May-15' and trunc( CUTTING_PRODUCTIVITY.PROD_DATE ) <='31-May-15'
ORDER BY CUTTER]]>
</queryString>
<field name="EST_CUTTER_GLASSES_QTY" class="java.math.BigDecimal"/>
<field name="CUTTER_NET_SQM" class="java.math.BigDecimal"/>
<field name="REMAKE_CUT_QTY" class="java.math.BigDecimal"/>
<field name="PROD_DATE" class="java.sql.Timestamp"/>
<field name="REMAKE_CUT_SQM" class="java.math.BigDecimal"/>
<field name="CADENCY" class="java.math.BigDecimal"/>
<field name="USER_QUANTITY" class="java.math.BigDecimal"/>
<field name="CUTTER" class="java.lang.String"/>
<field name="MACHINE_WORKING_HOURS_NORM" class="java.math.BigDecimal"/>
<group name="CUTTER">
<groupExpression><![CDATA[$F{CUTTER}]]></groupExpression>
<groupHeader>
<band height="325">
<frame>
<reportElement x="0" y="0" width="555" height="325" printWhenGroupChanges="CUTTER"/>
<multiAxisChart>
<chart renderType="svg" theme="generic">
<reportElement x="24" y="0" width="486" height="325">
<property name="net.sf.jasperreports.chart.range.axis.tick.interval" value="2"/>
</reportElement>
<chartTitle/>
<chartSubtitle/>
<chartLegend position="Bottom"/>
</chart>
<multiAxisPlot>
<plot/>
<axis>
<lineChart>
<chart renderType="svg">
<reportElement x="0" y="0" width="0" height="0" backcolor="#FFFFFF"/>
<chartTitle color="#000000"/>
<chartSubtitle color="#000000"/>
<chartLegend textColor="#000000" backgroundColor="#FFFFFF" position="Bottom"/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="chart1">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["WEIGHTAVG"]]></seriesExpression>
<categoryExpression><![CDATA[$F{PRODDATE}]]></categoryExpression>
<valueExpression><![CDATA[$F{NVL(Q.M2NETREEL,0)}]]></valueExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["OBJECTIF"]]></seriesExpression>
<categoryExpression><![CDATA[$F{PRODDATE}]]></categoryExpression>
<valueExpression><![CDATA[$F{OBJECTIF_HMOBY1000}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot isShowLines="true" isShowShapes="true">
<plot labelRotation="-45.0"/>
</linePlot>
</lineChart>
</axis>
<axis>
<barChart>
<chart renderType="svg">
<reportElement x="0" y="0" width="0" height="0" backcolor="#FFFFFF"/>
<chartTitle color="#000000"/>
<chartSubtitle color="#000000"/>
<chartLegend textColor="#000000" backgroundColor="#FFFFFF" position="Bottom"/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="chart1">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["M2NetHMO"]]></seriesExpression>
<categoryExpression><![CDATA[$F{PRODDATE}]]></categoryExpression>
<valueExpression><![CDATA[$F{M2NETBYHMO}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot/>
<itemLabel/>
</barPlot>
</barChart>
</axis>
</multiAxisPlot>
</multiAxisChart>
</frame>
</band>
</groupHeader>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="50"/>
</title>
</jasperReport>
如何将条形图轴向右移动?
答案 0 :(得分:0)
要在jasper报告中将轴移动到图表的右侧,您需要为图表创建自定义程序。完成此操作后,自定义程序中的以下命令会将轴移动到图表的右侧:
// get plot from chart object
CategoryPlot plot = (CategoryPlot) chart.getPlot();
// move axis to right side of chart
plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);