Jump to content
We've recently updated our Privacy Statement, available here ×

Create an ad hoc multi-year line graph


beverleym

Recommended Posts

I am using JasperReports Server Professional 7.1 (web interface)

I'm trying to create an AD HOC VIEW line graph that has one line for each year of my date field, similar to the example at the top of  https://www.pivot-table.com/2014/05/14/compare-years-in-pivot-chart/ but instead I'm getting a single line for the entire time series, more like the example shown on that web page under "Create a pivot chart".

I have mine grouped by Month, but I'm still only getting a single line and the X axis has January 2016 at the far left and October 2019 at the far right.  What I want is January at the left and December at the right, and a line for 2016, a different line for 2017, etc.

The layout I have currently which is the closest I can get is:

  • Chart Type: Line graph
  • Columns: A calculated field counting the number of results
  • Rows: my date field, grouped by month
  • Rows data slider all the way at the right

Any assistance would be greatly appreciated.

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

After posting the above, I found "Time Series" but it won't allow me to select Month, only Day or less.  I need to compare 10 years of data so Day will be very messy .. and it still seems to want to do it as a series of days from first to last rather than multiple lines.

Link to comment
Share on other sites

@danoldenkamp I thought I had done that, but perhaps I hadn't done all the things at the same time.

 

What I've got now is a calculated Field for year with formula = Year("Ignition Date/Time") in the Columns section, along with a calculated Measure for Num with formula = 1.  In the Rows section, I have another calculated Field for month with formula MonthNumber("Ignition Date/Time").

 

This seems to be pretty close to what I was looking for.  I was hoping for "January" rather than 1, but if I use the MonthName formula instead, it puts them in alphabetical order so it starts with April and August and ends with September.  So I guess I can do a concatenate of both to do 1-January etc. 

Link to comment
Share on other sites

What about using the month numbers as category and just use an expression for the category labels?

(e.g.

new SimpleDateFormat("MMMM").format(java.sql.Date.valueOf(LocalDate.of(2019,$F{YourMonthNumberField},1)))  [/code]

So this will probably sort chronological but render the month names. ;-)

hth + regards

C-Box

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