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

Creating chart from xml datasource


cristic83

Recommended Posts

Hello,

I have tried to use JasperReports and followed the tutorials on the project website,but I'he ran into problems when trying to create a report which contains charts and uses XML datasource files for filling the report.

I am trying to create a report that contains a chart and is using an XML datasource to fill the report, but when the report is generated one chart is generated for every record from my XML datasource.

The steps I took using iReport Designer 3.7.6 were:

1) Create an empty report

2) Add an XML datasource to the report. The query language I selected is XPath, the record node: /genericSingleReport/data/data and the fields were: count and timestamp. The XML datasource file looks like this:

<genericSingleReport>
<data>
<data>
<count>388.0</count>
<timestamp>1288864800000</timestamp>
</data>
</data>
</genericSingleReport>

3) I added a BArChart(or Pie Chart or XY chart) to the detail section of the report , selected the main report dataset in the first step in the wizard, the the value:

DateFormat.getDateInstance().format(new Date(Long.valueOf($F{timestamp}))) for the Category expression

and:

Double.valueOf($F{count}) for the value expression

When I preview the report I get as many charts as data records in the XML datasource file and each chart represent the first entry in the XML file, so I have n entries for the 388 value in hte above example. This, of course, is not what I need, because I want one chart which displays all the values.

Thanks for your help,

Cristi

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 2 weeks later...

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