Jump to content

How to draw a chart with multiple


rainer.stuelp

Recommended Posts

Hi,

I am using JAVA with beans to create a jasper report with a chart that has two series.

The data I put to tje JasperFillManager has the following structure:

public class Dot {  Double x;  Double y;// Getter and Setter here ...}public class Payload {  ArrayList<Dot> defaultPoints;  ArrayList<Dot> sprintPoints;  // Getter and Setter here ...}...Map<String,Object> parameters = new HashMap<String,Object>();Payload payload = new Payload();// fill payload with values for defaultPoints and sprintPoints...parameters.put("payload", payload);...JasperPrint jasperPrint = JasperFillManager.fillReport(reportPath, parameters);[/code]

I have a main report (including a parameter "payload") which contains a subreport. In the subreport I want to draw the chart. The subreport has the paraneter "payload", too and the main report is passing the value to the subreport.

The subreport has two fields:

x: java.lang.Double
y: java.lang.Double

I inserted a char element (XY Line) and set Y value to $F{y} and X value to $F{x}.

I have added two series. How can I assign defaultPoints to Series 1 and sprintPoints to Series 2?

Regards,

Rainer

 

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I found a solution how it works.

public class Dot {  Long x;  Double y;  String graphName;// Getter and Setter here}public class Chart {  ArrayList<Dot> punkte;// Getter and Setter here}[/code]

Each dot needs to know to which series it belongs.

So, the series value must be $F{graphName}

JasperReports detects a new series name and starts with a new series

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