Do multiple chart lines typically require multiple columns in the dataset?

I'm new to JasperReports and am using iReport Designer 4.5.0 to play around with how to generate charts.

In this case, I am trying to generate a line chart, which in the simple case, might show three lines,Lline1, Line2 and Line3, where line1 and 2 are independant data, and Line3 is perhaps some combination of the two [e.g. an average such as (Line1+Line2)/2)].

I've been trying to familiarize myself with what kind of datasets are required for the charts, and as far as I've found so far, it appears that to accomplish the scenario described above, my database query would at a minimum be required to return three columns of data:

  1. Category
  2. Line1 Value
  3. Line2 Value

(Then I can calculate Line3 in a variable, or on the fly in the chart value field).

However, due to the nature of my data, this requires me to do multiple joins on the table in order to get Line1 and Line2 data to be two adjacent columns. I'm concerned that this may get out of hand if I need to work with more and more Lines. In fact, in my original data has columns more like this:

  1. Category
  2. LineNumber
  3. Value

However, I couldn't seem to get the reporting tool to show two different trend lines based on a dataset like this?

Is there a way to do chart based on this type of data?

ee.ashley's picture
Joined: May 21 2013 - 7:57am
Last seen: 8 years 9 months ago

1 Answer:

No, just use a series expression:

  • LineNumber (series expression)
  • Category
  • Value

where the line number can also be a nice name, which is shown in the legend.

With the disadvantage, that you will have to extra-query the average line. Or you do this within a chart customizer.

Cheers, Thomas

Thomas Zimmer's picture
Joined: Oct 2 2012 - 1:35am
Last seen: 2 days 22 hours ago