How to draw a chart with multiple

0

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);

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

rainer.stuelp's picture
Joined: Jan 28 2020 - 10:04am
Last seen: 1 month 1 week ago

1 Answer:

0

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
}

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

rainer.stuelp's picture
Joined: Jan 28 2020 - 10:04am
Last seen: 1 month 1 week ago
Feedback