I am using JasperReports and I would like to generate charts for different objects from same POJO class. POJO Class looks like below:
public class POJOClass{ private Double value; private long timestamp; //constructor+getters
What do I want to do?
In first step I would like to fill chart from value of first object.
Then I would like to add next page and go into second step of loop, get from database next object and fill chart in 2nd page.
I am using same POJO however both objects has different value. The problem is that I can fill only one page.
InputStream jasperStream = this.getClass().getResourceAsStream("generate.jrxml"); JasperDesign design = JRXmlLoader.load(jasperStream); for (int i = 0; i < size; i++) { List<POJOClass> pojoDescribtions= new ArrayList<>(); //add some result into List JRDataSource jrDataSource = new JRBeanCollectionDataSource(pojoDescribtions); parameterMap.put("datasource", jrDataSource); jasperPrint = JasperFillManager.fillReport(report, parameterMap, jrDataSource); }
It always create chart for 2nd step and I do not know how to get also for the first one.
1 Answer:
Posted on May 8, 2018 at 3:11am
Try
List<POJOClass> pojoDescribtions= new ArrayList<>(); for (int i = 0; i < size; i++) { //add some result into List } JRDataSource jrDataSource = new JRBeanCollectionDataSource(pojoDescribtions); parameterMap.put("datasource", jrDataSource); jasperPrint = JasperFillManager.fillReport(report, parameterMap, jrDataSource);
Also make sure your chart is placed in the detail band of the report.