Sunday, May 11, 2014

Jaspersoft HTML5 charts remove decimal (where not required) from tooltip

For those of you who dont know Jaspersoft use HighCharts js library for its HTML5 (dynamic) charts. We were facing this problem of Jaspersoft adding a decimal (XX.00) for all values in the tooltip. This is very disconcerting when the measure is an Integer, like Number of Users, etc. 

We thought that, may be our domain query or our data store was to blame for it and was returning decimal but it was not.

HighCharts tooltip has a property called valueDecimals which determines how may decimal positions it should show. 

Just add this line to getCommonSeriesGeneralOptions method in /var/lib/tomcat7/webapps/jasperserver-pro/scripts/adhoc/highchart.datamapper.js and live happily ever after :).

options.tooltip.valueDecimals=0;

This will add a decimal only if you give one. So all your floats (coming from data store) will remain floats and integers will remain integers.