Jump to content
We've recently updated our Privacy Statement, available here ×

Piechart generated from JRBeanCollectionDataSource appears empty


alouloubrand

Recommended Posts

Hi everyone, I've been struggling with this for so long and I really need help...

 

I am trying to create a piechart using a Java collection. The java collection is a collection of  "StatsRegles" objects, that contains two attributes: id (Integer) and triggerNumber (Integer)

Cuurent Problem: The piechart appears in the report as an empty picture (no chart, no errors displayed, nothing, just a frame with an invisible content)

I am first creating the JRBeanCollectionDatasource:

JRBeanCollectionDataSource statsReglesDataSource = new JRBeanCollectionDataSource(statsRegles);  (statsRegles is of type ArrayList<StatsRegle>)ClientReportInput.setStatsReglesDataSource(statsReglesDataSource);

then I am adding it to the parameters hashmap, used to generate the report:

parameters.put("statsReglesDataSource", getStatsReglesDataSource());

 

As for the ClientReport.jxml file, here is the parameter declaration:

<parameter name="statsReglesDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>

 

here is the subdataset declaration

<subDataset name="StatsRegleDataSet" uuid="ac90ea90-c198-4832-984f-e11509730f69">    <queryString>        <![CDATA[]]>    </queryString>    <field name="id" class="java.lang.Integer"/>    <field name="triggerNumber" class="java.lang.Integer"/>    <sortField name="id"/></subDataset>

 

and here is the interesting part, the piechart implementation:

<pieChart>    <chart evaluationTime="Report">        <reportElement x="150" y="10" width="220" height="200" uuid="ac8924b1-92f8-45f4-aaa7-52fe05a0d403"/>        <chartTitle/>        <chartSubtitle/>        <chartLegend/>    </chart>    <pieDataset maxCount="10">        <dataset resetType="Report">            <datasetRun subDataset="StatsRegleDataSet" uuid="4e4e4127-1b96-4155-8be6-2f644f8a9c4b">                <dataSourceExpression><![CDATA[$P{statsReglesDataSource}]]></dataSourceExpression>            </datasetRun>        </dataset>        <keyExpression><![CDATA[$F{triggerNumber}]]></keyExpression>        <valueExpression><![CDATA[$F{triggerNumber}]]></valueExpression>        <labelExpression><![CDATA["Regle "+$F{id}.toString()]]></labelExpression>    </pieDataset>    <piePlot>        <plot/>        <itemLabel/>    </piePlot></pieChart>


 

 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...