Jump to content
We've recently updated our Privacy Statement, available here ×

Cannot set xAxis properties in HTML5 highcharts


ross.yuexin.zhu

Recommended Posts

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...
 

 

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...