beverleym Posted November 2, 2019 Share Posted November 2, 2019 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 graphColumns: A calculated field counting the number of resultsRows: my date field, grouped by monthRows data slider all the way at the rightAny assistance would be greatly appreciated. Link to comment Share on other sites More sharing options...
beverleym Posted November 2, 2019 Author Share Posted November 2, 2019 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 More sharing options...
danoldenkampgmail.com Posted November 5, 2019 Share Posted November 5, 2019 Put year in the chart series. Add year to your dataset. (use an expression to extract)Edit the chart and select the Year as the series, the month as the category, and your calculated field as the value. Link to comment Share on other sites More sharing options...
beverleym Posted November 5, 2019 Author Share Posted November 5, 2019 @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 More sharing options...
beverleym Posted November 5, 2019 Author Share Posted November 5, 2019 Nope. that doesn't help my sort issue. Now I get 1-January, then 10-October etc. Sigh. Link to comment Share on other sites More sharing options...
beverleym Posted November 5, 2019 Author Share Posted November 5, 2019 Ugly final formula.Concatenate(IF(MonthNumber("Ignition Date/Time") <= 9, '0', ''), MonthNumber("Ignition Date/Time"), '-', MonthName("Ignition Date/Time")) Is there a better way?? Link to comment Share on other sites More sharing options...
beverleym Posted November 5, 2019 Author Share Posted November 5, 2019 what I've got so far..... Screen shot should be below but it's not showing up.... you can also see it at https://ibb.co/6FZ97qg Link to comment Share on other sites More sharing options...
C-Box Posted November 6, 2019 Share Posted November 6, 2019 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 + regardsC-Box Link to comment Share on other sites More sharing options...
beverleym Posted November 6, 2019 Author Share Posted November 6, 2019 @C-BoxI sure wish I could comment directly on the answers. I don't think I can use that Java code in the web interface. There aren't categories, etc. Only Columns and Rows. See screen shot link in previous comment. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now