Search code examples
highchartsjasper-reportsjaspersoft-studio

HTML5/High Charts - Truncate xAxis Labels


Could someone help me truncating the labels on the Highcharts in Jaspersoft Studio?

So following the instructions from this link (How do I format x-axis label in highcharts) I have come up with the below:

<hc:chartProperty name="xAxis.labels.formatter">
    <hc:propertyExpression><![CDATA[function(){return this.value.toString().substring(0, 3)}]]></hc:propertyExpression>
</hc:chartProperty>

However this is causing the report to fail.

Has anyone truncated the labels on a highchart through Studio before? Could you provide an example on how to do this? I'm doing this on a stacked column chart. Any help would be much appreciated.


Solution

  • Solved this,

    So: 1. In Tools->Options->JasperReports properties add

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

    1. Add quotes to expression

    <hc:chartProperty name="xAxis.labels.formatter"> <hc:propertyExpression><![CDATA["function(){return this.value.toString().substring(0,3)}"]]></hc:propertyExpression> </hc:chartProperty>