Jaspersoft BI Tools

iReport,Jaspersoft Design Studio,Jaspersoft Server, Schema Workbench,Analysis,Dashboards, Self Service BI, Domains,Topics,Ad-Hoc Reports, Jaspersoft ETL, Embedding BI,HTML-5 charts, Fusion Charts,JFree Charts,Drill down reports , Drill down Dashboards,Visualize.js, Performance Tuning, D3 Charts, Jaspersoft Customization

Monday, March 07, 2016

HTML-5 Charts advanced properties best practices in Japser Reports (Uncaught Java Script Error & TypeError: Cannot find function add in object 0 com/jaspersoft/jasperreports/highcharts/charts/render/scripts/highcharts-4.0.3.bbox.js#1969)

Hi All,

In Jasper Reports, when working with Advanced Chart Options with HTML-5 charts, you may experience Uncaught Java Script Error message and while exporting the report you may get below error.

Error Message

net.sf.jasperreports.engine.JRRuntimeException: org.mozilla.javascript.EcmaError: TypeError: Cannot find function add in object 0. (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/highcharts-4.0.3.bbox.js#1969)
Error Message

org.mozilla.javascript.EcmaError: TypeError: Cannot find function add in object 0. (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/highcharts-4.0.3.bbox.js#1969)

How to overcome & What are the best practices while working with Advanced chart properties ? 

1) Point out your query fields to the graph (any graph from HTML-5).
2) For every change in your JRXML (report or chart level) publish to the server and check the export. (Check the output in 4 different browsers IE or Edge , Mozilla, Chrome and Safari).
3) The above problem comes when you add advanced Properties.

 For example: When you add linearGradient property in Advanced Section
chart.backgroundColor.linearGradient = java.util.Arrays.asList(0,0,500,500)
You should check the expression checkbox for the property because the value of the property is written in Java. 

4) Do not use direct values like 3 , 4 or some thing like that instead use parser functions like new Integer(3) or new Integer(4).

5) Also when adding a variable or field with integer follow this method :  
Preferable : $V{someVariable}+new Integer(4) or $F{someField}+new Integer(60)
Not Preferable : $V{someVariable}+4 or $F{someField}+60 

6)  yAxis tick interval
Wrong :

<hc:chartProperty name="yAxis.tickInterval" value="10"/>
Correct : 
<hc:chartProperty name="yAxis.tickInterval"><hc:propertyExpression>
<![CDATA[new Integer(10)]]>
7) Similarly with all other properties that you take from HTML-5 API should go in the way that the Studio engine can understand the script and exportable into PDF.

I hope this helps someone. !

Thank you.
Sadakar Pochampalli