0
如何使用jaspersoft製作動態放樣的條形圖。目前值列不接受值列表,而是需要一個整數。我期待圖表循環遍歷我通過的列表。java中的堆疊條形圖和eclipse中的jasperSoft studio插件
public class TeamPerformance {
public List<TeamData> getReport(String reportId) {
List<ContractionsPartogramData> result = new ArrayList<>();
ContractionsPartogramData data = new ContractionsPartogramData();
List<String> cat = new ArrayList<>();
cat.add("11:00");
cat.add("12:00");
cat.add("13:00");
List<Integer> teamOneScore = new ArrayList<>();
teamOneScore.add(1);
teamOneScore.add(11);
teamOneScore.add(13);
List<Integer> teamTwo = new ArrayList<>();
teamTwo.add(4);
teamTwo.add(14);
teamTwo.add(5);
data.setTeamOne(teamOneScore);
data.setTeamTwo(teamTwo);
data.setTeamOneSeries("Team One");
data.setTeamTwoSeries("Team Two");
data.setCategories(cat);
result.add(data);
return result;
}
}
的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="mbp_baby" pageWidth="1684" pageHeight="1190" orientation="Landscape" columnWidth="1150" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8f9fcfe4-de3f-44f2-a894-dd075a99d88e">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<subDataset name="BabyVisitsDataset" uuid="397116d3-884b-412b-aac0-f71201d3be28">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
</subDataset>
<detail>
<band height="343" splitType="Stretch">
<staticText>
<reportElement x="79" y="59" width="99" height="20" uuid="af169a41-c5d0-49b5-87fb-b820c543167f"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font isBold="true"/>
<paragraph leftIndent="5"/>
</textElement>
<text><![CDATA[Teams]]></text>
</staticText>
<stackedBarChart>
<chart evaluationTime="Report">
<reportElement x="43" y="78" width="200" height="200" uuid="ff603b1a-74f7-4c48-95a3-bbd94f9a2811"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[$F{teamOne}]]></seriesExpression>
<categoryExpression><![CDATA[$F{categoryArray}]]></categoryExpression>
<valueExpression><![CDATA[$F{arrayTeamOneValues}]]></valueExpression>
<labelExpression><![CDATA[]]></labelExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA[$F{teamTwo}]]></seriesExpression>
<categoryExpression><![CDATA[$F{categoryArray}]]></categoryExpression>
<valueExpression><![CDATA[$F{arrayTeamOneValues}]]></valueExpression>
<labelExpression><![CDATA[]]></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>
</stackedBarChart>
</band>
</detail>
</jasperReport>
錯誤堆棧跟蹤:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Number
at net.sf.jasperreports.charts.fill.JRFillCategorySeries.evaluate(JRFillCategorySeries.java:141)
at net.sf.jasperreports.charts.fill.JRFillCategoryDataset.customEvaluate(JRFillCategoryDataset.java:110)
at net.sf.jasperreports.engine.fill.JRFillElementDataset.evaluate(JRFillElementDataset.java:160)
at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:187)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:735)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414)
at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:736)
at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:221)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
謝謝亞歷克斯我在格式化源代碼時遇到了困難。 – joseph