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

Jaspersoft Studio: How to get the right Labels within a Pie Chart (HTML5)


chriss_1985

Recommended Posts

Hello Community,

I would like to create a pie chart (HTML5) within Jaspersoft Studio (6.1.0).

My data source is following table:

COLOR  | NUMBER | NUMBER_STRING
-------------------------------
Green  | 3      | '3'
Yellow | 7      | '7'
Red    | 5      | '5'
Grey   | 4      | '4'


My pie chart should contain four sections:

- A green section  (Size: 3/19 of the circle; Label in the section: '3')
- A yellow section (Size: 7/19 of the circle; Label in the section: '7')
- A red section    (Size: 5/19 of the circle; Label in the section: '5')
- A grey section   (Size: 4/19 of the circle; Label in the section: '4')

Problem: The labels don't show values from the attribute NUMBER.

Some of my pie chart settings:

> Chart Data -> Configuration -> Categories Levels:
- Expression: $F{COLOR}

> Chart Data -> Configuration -> Value:
- Label Expression: $F{NUMBER_STRING}
- Value Expression: $F{NUMBER}

> Chart Properties -> Colors Palette:
- "Green, Yellow, Red, Grey"

Result: Everything works. I get four pies in right size and color.
             But for the labels I get the values from the attribute COLOR.
             Not from the attribute NUMBER (or NUMBER_STRING).

Thanks for your help.
Chris

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

The Chart Data/Configuration/Value/Label Expression is somewhat misleading, it's actually a label for the measure/series itself (like "Sales Amount" or "Number of items").

If you want to specify a label for each point/item in the series, you'll have to do the following:

  • In the category level, add a Bucket Property called NumberString, using $F{NUMBER_STRING} as expression.
  • In Value/Advanced properties, add a property with SeriesItemProperty as Contributor, label as Property Name and Level1.NumberString as Bucket Value.
  • In Chart properties, add a property called plotOptions.pie.dataLabels.format using {point.label} as value.

Attaching a JRXML with the solution described above.

Regards,

Lucian

Link to comment
Share on other sites

  • 3 years later...

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