Cannot set xAxis properties in HTML5 highcharts

1

Hi,

I am currently using HTML5 charts in iReport and having trouble with setting highcharts properties. An interesting thing is that yAxis properties have no issue at all, e.g. yAxis.title.text, but things are different in terms of xAxis. For instance, below properties will never take effect:

  xAxis.labels.enabled

  xAxis.type

  xAxis.dateTimeLabelFormats

In the html (javascript) file Jasper generated, I see:

 

(function() {
var highchartsConfig_1446678858_0_394069723={"chart":{"defaultSeriesType":"line"},"xAxis":[{"categories":["1362114000000","1362114900000","1362115800000","1362116700000","1362117600000","1362118500000","1362119400000","1362120300000" ...}
JRDefaultHighchartsSettingService.setProperty(highchartsConfig_1446678858_0_394069723,'xAxis.labels.enabled',false);
JRDefaultHighchartsSettingService.setProperty(highchartsConfig_1446678858_0_394069723,'yAxis.title.text','Y Axis');
 
So, obviously, any properties applied to xAxis are invalid since the original xAxis is an array, instead of a hash. Properties should rather be set on xAxis[0] instead of on xAxis. if we make below modification in the html:
JRDefaultHighchartsSettingService.setProperty(highchartsConfig_1446678858_0_394069723,'xAxis.0.labels.enabled',false);

Then everything works beatifully....

However, it appears that I couldn't simply define xAxis.0.labels.enabled = Boolean.FALSE as a chart property in iReport. I got below error during data filling:

 

Error exporting print... Invalid chart property name xAxis.0.labels.enabled 
net.sf.jasperreports.engine.JRRuntimeException: Invalid chart property name xAxis.0.labels.enabled     at com.jaspersoft.jasperreports.highcharts.charts.services.DefaultChartSettingService.perform(DefaultChartSettingService.java:66)     at com.jaspersoft.jasperreports.highcharts.charts.StandardPrintChartCreator.getPrintChart(StandardPrintChartCreator.java:72)     at com.jaspersoft.jasperreports.highcharts.charts.ChartHtmlHandler.generateChartHtml(ChartHtmlHandler.java:90)     at com.jaspersoft.jasperreports.highcharts.charts.ChartHtmlHandler.getHtmlFragment(ChartHtmlHandler.java:70)     at net.sf.jasperreports.engine.export.JRHtmlExporter.exportGenericElement(JRHtmlExporter.java:2509)   
 
yAxis doesn't have this problem only because the original highchartsConfig_1446678858_0_394069723 doesn't have yAxis property.
 
I just don't understand why xAxis is defined as an array at the first place, and why xAxis.0.labels.enabled is an invalid property. Any ideas? I need to define xAxis properties because there are many points in my graph, and the xAxis labels overlap on each other...
 

 

ross.yuexin.zhu's picture
Joined: Apr 1 2013 - 5:38pm
Last seen: 1 year 3 months ago
Did you find a workaround? I am having the same issue.
israel_1 - 6 years 10 months ago
Failing to find a more elegant solution, I modified /jasperreports-server-5.0.1/ireport/ireportpro/scripts/default.service.js. Add: if (tokens[idx] == 'xAxis') { subobj = obj['xAxis'][0]; }
ross.yuexin.zhu - 6 years 10 months ago

0 Answers:

No answers yet
Feedback