Display % Value in Pie Chart – Jaspersoft Studio

Home  >>  Jaspersoft Studio  >>  Display % Value in Pie Chart – Jaspersoft Studio

Display % Value in Pie Chart – Jaspersoft Studio



In this topic I am going to show you how to achieve the following custom formatting of data labels in a pie chart using Jaspersoft Studio.

1) How to Show Data Labels.

2) How to Show % Values using Jaspersoft Studio.

3) How to display % value using a Customizer

4) How to display the Labels within the slice using a Customizer


How to Show Data Labels.

In Jaspersoft Studio Default data labels can be enabled or disabled by the option “Chart Plot” under Chart Properties (As shown Below)

Show Labels (www.rajeshsirsikar.com)

This will enable only the default Data Labels provided as part of the Chart Theme in JasperSoft Studio.

How to Show % Values using Jaspersoft Studio.

If we want to have a completely different set of Data Labels (Ex : % Value in a pie Chart which is not present in the Default Theme) then we need to follow the below mentioned steps to achieve the same

Default Theme would give the Pie Chart as follows (Without % Value and the Data Labels are outside the slice)

Pie Chart (www.rajeshsirsikar.com)

If we use {2} as the Label Format we can Display % Value instead of the Label as Follows

a)      Label Format is empty and Hence the report display will be as below

Pie Chart1( www.rajeshsirsikar.com)

b)      Label Format is {2} and then the % Value Shows up

Pie Chart2( www.rajeshsirsikar.com)

c)      If we use the Label format as {0}{2} Then both Label and % Will show up

Pie Chart3( www.rajeshsirsikar.com)

By following these steps , we can modify the data display on the Data Labels of teh Pie Chart.

We can just use {0} to show the Data Key

{1} to show the Data Label

{2} to show the % Value

and we can use the Combination of these Three for different set of Customization to these data Labels.

If we want to show the % Values of the Pie Slices inside the Pie Chart, then we need to use Customizer Class to achieve the same. I will discuss Customizer Class, Its Implementation and Use in my next post. I will also explain how to display the Pie Chart Data Labels inside the Slice.

6 Comments so far:

  1. Kate says:

    Good day.
    Could you help me?
    I try to write report for JasperReport.
    Report with charts.
    But my reports isn’t working with MAIN DATASET, it’s working only with SUB DATASET. This problem is important for me, because I need use parameters.

    Use parameters with sub dataSet is second problem for me. (maybe you can give me link with explanations?)

    I use iReport 5.6.0, TIBCO JasperSoft Studio 6.0.3, Jasper Server 6.0.1

    For earlier Thank you very much.

    This code (working only number 1 (sub dataset), number 2 isn’t working):

  2. Cristian says:

    How do I can put the values (%) with decimals?

    Such as 5.45%

    Greetings and thanks

    • rajeshsirsikar says:

      Hey Cristian,

      This is not possible, if you are using Label Format as {2}. But we can achieve it by following methods
      1) Create a Customizer Class.
      2) Create a Percentage Variable at report level and use that in Chart.

      Rajesh S

    • rajeshsirsikar says:

      I will update my Chart Customizer blog with a example bit and the code. Check that out

  3. saurabh singh says:

    thanks it was very helpful .

Leave a Reply

Your email address will not be published. Required fields are marked *