Functions can be used to format html5 datalabels and tooltips

Issue Description:

Html5 chart Tooltips values can be formatted using highchart's functions.  Following is an example of such tooltip formatting directly via javascript calls (unrelated to JasperReports Server): 

http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/tooltip/formatter-simple/


Resolution:

Since JasperReports Server version 5.1, you can take advantage of these highcharts functions to impact things like tooltips as well as datalabels.

First, add this line to \WEB-INF\classes\jasperreports.properties and restart the server:

com.jaspersoft.jasperreports.highcharts.function.properties.allowed=true

Then specify javascript function as strings within your expressions for advanced properties, like tooltip.formatter or plotOptions.pie.dataLabels.formatter. The resulting jrxml would be like:

<hc:chartProperty name="plotOptions.pie.dataLabels.formatter">
   <hc:propertyExpression>
      <![CDATA["function() {return '<b>something bold</b>: '+this.point.y;}"]]>
   </hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="tooltip.formatter">
   <hc:propertyExpression>
      <![CDATA["function() {return 'something with percent char: '+this.point.y+'%';}"]]>
   </hc:propertyExpression>
</hc:chartProperty>

Sample jrxml attached using sugarcrm datasource.

Note that JasperReports Server v5.5 contains a bug (35210 ) which effects the behavior of these functions. The cumulative hotfix patch for JasperReports Server v5.5, available upon request from support, will resolve the bug (note that hotfixes are available for customers with Premiun Subscription only).


Reference:


Ref. Case #00034325

Attachments: 
Feedback
randomness