Jump to content

Helping generating charts


Recommended Posts


I want to do a template to output a pdf with a bar chart. Each column of this chart is a field of my model (with just a single series). My problem is I don't know how I do this. I already try to search, bt everywhere are for mutiple series, for list or for table of database.

Can someone tell me how I do this. I'm very new to Jasper.

My model (the chart fields, where each field is a bar value)

public class Report {    private Double f1;    private Double f2;    private Double f3;        public Double getF1(){        return f1;    }    public Double getF2(){        return f2;    }    public Double getF3(){        return f3;    }}[/code]

To compile and generating the PDF:

Report report = getSelectedReport();HashMap<String, Object> parameters = new HashMap<>();parameters.put("dataChart", report);JasperReport jasperReport = JasperCompileManager.compileReport(reportSrcFile);ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();list.add(parameters);JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(list);JasperPrint print = JasperFillManager.fillReport(jasperReport, null, beanColDataSource);  [/code]


Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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