Jump to content

Mixing crosstab and pie chart


acore

Recommended Posts

Hello. I am newbie to iReport and JasperReports and I want to ask you for help to make certain kind of report. I had read iReport ultimate guide but I don't know how to proceed with it.

I have a dataset with 2 columns, A and B. Each colum have an indeterminated number of possible values (it is not possible to know the number of possible values in design-time). For this columns I need to make a crosstab showing the count of each combination of the values (this is not a problem) and two pie charts (one for each column), showing the distribution of each variable separately. I attached a sample of the report I want to make.

I know how to make the crosstab and also how to make each pie chart using a sql query like "select A, count(*) from table group by A", and I can make the desired report using different datasets giving distinct sql expressions for each (like in the sample attached)

The problem is that I need to use a JavaBean Collection dataset instead of a connection and I dont know how to proceed for make this report. The beans have the 2 fields A and B (with corresponding getA() and getB()). This report will be generated from a java class and my idea is to call fillReport with a JavaBean collection datasource.

Could you give me any idea for make this report?

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

it's simple:

List<Cat> cats= new ArrayList<Cat>();
cats.add(cat1);
cats.add(cat2);
...
...
...
JRBeanCollectionDataSource datasource = new JRBeanCollectionDataSource(cats);
JasperReport jasperReport = JasperCompileManager.compileReport("yourreportpath.jrxml");
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), datasource);
JasperExportManager.exportReportToPdfFile(jasperPrint, "yourreportpath.pdf");

 

in the report be sure you use the proper field name registering them.

_________________________________________

if it works... give me KARMA points please!    : )  
_________________________________________


listening: Air - La Femme D'Argent 

Link to comment
Share on other sites

Thanks for your reply.

Perhaps I did not explain my problem correctly. I know how to use a JavaBean DataSource, this is not the problem.

The problem is that if I give the JavaBean Datasource as you suggest, the collection of cats only will be used as the main datasource of the report, that in my desing is used only for generating the crosstab. The two charts needs special queries including a count(*) and group by in each of it and if I pass the JavaBean Datasource I can't do this operations as I need a sql connection.

Probably exists another aproach to design the report, but I dont know... any other idea?

Link to comment
Share on other sites

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