Limiting Scheduled Reports Against Holiday Dates in JasperServer

A new feature added to JasperServer 5.1 is the ability to create a calendar that can be referenced as a list of dates on which to exclude sending scheduled reports.

For example, you may have a report of Cost of Labor data that is scheduled to be sent at the end of day at a time after your employees are clocked out. On any business day, you might want to compare your cost of labor to the sales made that day. However, you may not want to receive the email on closed days.

Currently, the ability to modify exclusion calendars is only available using the JasperServer REST 2.0 services. The API reference for this ability is located on the Jaspersoft Community site: Adding or Updating an Exclusion Calendar

So, using the Firefox plugin Poster, I made a PUT request to my local instance of JasperServer to add a calendar named ChristmasHolidays of Christmas and Christmas Eve dates for the next couple of years:

jasperserver-add-exclusion-calendar-poster

After clicking the POST button to submit the calendar to JasperServer, I receive an OK 200 Response:

jasperserver-add-exclusion-calendar-poster-response

Now, when I attempt to schedule a report, my ChristmasHolidays displays as an option to exclude report scheduling against when a reoccurring schedule type is selected:

jasperserver-add-exclusion-calendar-results

This feature is definitely more useful when including all of a businesses holidays because currently multiple calendars cannot be selected for exclusion when scheduling a report. Hopefully Jaspersoft will incorporate custom calendars in other parts of the application – specifically the ability to use custom calendars as an inclusion option, the ability to select multiple calendars for inclusion/exclusion, and integration into the date selector input controls within reports.

If you have any other ideas or good uses for this feature, please comment below!

Customizing Tooltips in JasperReports HTML5 Chart Components

Note: I am referencing the 5.5 versions of JasperServer, iReport, and JasperStudio in this post.

Since HTML5 Charts have been added to JasperReports in its 5.0 release, a slew of new graphing possibilities have been made available. Some of the abilities to customize these charts have not been implemented in the graphical reporting tools iReport and JasperStudio in the most intuitive way. Details on how to customize them have not been easy to find either. Here is an example of an HTML5 Stacked Bar Chart from the demo data in a report displayed in JasperServer:

Customizing Tooltips in JasperReports HTML5 Chart Components

Displaying the Category (“CA”), Series (“Male”), and Measure (“81,541.81”) when hovering over a chart measure is sufficient in most cases, but there are often more datapoints that would be nice to have displayed in the tooltip. For example, a percentage across the category the would be a great addition. To add this, right click on the chart element in iReport or JasperStudio and select “Edit Chart Properties,” the button indicated below:

Customizing_Tooltips_in_JasperReports_HTML5_Chart_Components_Chart_Properties

Here, you can add custom properties. You should see a list of currently set properties that were either predefined, or customized using the properties panel in iReport or JasperStudio. You can edit these properties by double-clicking a property to bring up an expression editor. To customize the tooltip, you need to click the add button as seen below:

Customizing_Tooltips_in_JasperReports_HTML5_Chart_Components_Chart_Properties_Advanced

Now an expression editor will display. In this example, we want to show what we are currently displaying with an additional percentage amount. Here, we are going to set the “Property Name” as tooltip.pointFormat, check the “Use an expression” checkbox, and type the below string as seen in the image that follows:

Customizing_Tooltips_in_JasperReports_HTML5_Chart_Components_Chart_Properties_Advanced_Expression

Click OK on the expression editor window. Click OK on the HTML5 Charts properties window. You should be able to run the report now (or export to JasperServer and display) to have a result like this:

Customizing_Tooltips_in_JasperReports_HTML5_Chart_Components_Result 1

This is essentially what we wanted, but the precision of the percentage decimal value is not what we were looking for. To fix this, go through the process of adding another HTML5 Chart property. Set tooltip.percentageDecimals to “2” to achieve the result below:

Customizing_Tooltips_in_JasperReports_HTML5_Chart_Components_Result 2

Since HTML5 Charts use the HighCharts library, I recommend viewing their API documentation to uncover more potential options in customizing tooltips in HTML5 Charts in JasperReports.