Jump to content
Changes to the Jaspersoft community edition download ×

percentage % in HTML5 pie charts


Recommended Posts

Wow, you'd think it would be easier to get % or data labels in the pie slices!  Unless I'm missing something, you have to have a function as a custom property.  I've tried it, yet it won't display the % in the HTML5  pie slices.  Here's the code in the jrxml file:

<hc:chartProperty name="plotOptions.pie.dataLabels.formatter">    <hc:propertyExpression><![CDATA["function() {return Math.round(this.percentage*100)/100 + ' %';}"]]></hc:propertyExpression></hc:chartProperty>[/code]

I've also got

   <property name="com.jaspersoft.jasperreports.highcharts.function.properties.allowed" value="true"/>

but at the local level in JasperStudio 6.4 not sure that is relevant.

The pie chart is showing in Studio, just not with the %.  Anybody know what I'm missing?



Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

The answer below does help, and I appreciate the response.  Using the .format option with:

<hc:chartProperty name="plotOptions.series.dataLabels.format" value="{point.name} {point.percentage:.0f} %;"/>

It does show the name and % as part of the data label.  My intent/hope though is to keep the data label as the name only and put the % in the pie slice itself.  Has anybody successfully done that?

Link to comment
Share on other sites

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