Jasper report bar charts with list

0

I'm trying to do a report in Jasper and I want a bar chart. As parameter I have an object that contains a list of objects (label/value) that I want to do the chart. The problem is I don't know how I plot the chart with this list. For example:

I have the following object: 

public class ChartField {
    private String name;
    private double value;
 
    public ChartField(String name, double value) {
        this.name = name;
        this.value = value;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public double getValue() {
        return value;
    }
 
    public void setValue(double value) {
        this.value = value;
    }
}

and

public class Person{
   private String name;
   private List<ChartField> chart;
 
  public String getName(){
    return name;
  }
  public List<ChartField> getChart(){
    return chart;
  }
}

So for jasper I pass as datasource a list of Person.

The ideia is to each person I want to plot a bar chart with the list of ChartFields.

Can anyone advice me how to do this? Thanks

ajpcm1's picture
3
Joined: Sep 29 2018 - 3:09am
Last seen: 10 months 2 weeks ago

1 Answer:

0

Hi, 

I think you should use JRBeanCollectionDataSource(<List>) method.

you can refer below link: 

https://www.programcreek.com/java-api-examples/?api=net.sf.jasperreports...

 

Hope it works

 

Regards,

Miwa

miwagada's picture
Joined: Nov 23 2015 - 1:32am
Last seen: 6 months 3 weeks ago
Feedback
randomness