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

Create ONE pie chart for multiple result rows


rapthor

Recommended Posts

Hello,

I am new to Jasper Reports and iReports and wonder how it is possible to create a specific pie chart based on the following SQL statement:

 

SELECT
    SIZE,
    COUNT(SIZE) AS TOTAL
FROM
     APPARTMENT
GROUP BY
    SIZE

 

The table APPARTMENT looks like:

APPARTMENT

ID   |   SIZE
------------------------
1     |   MEDIUM
2     |   MEDIUM
3     |   SMALL
4     |   LARGE
5     |   SMALL
 

These are the requirements of the report I want to implement:

1) There should be only ONE pie chart (no matter how many result rows are returned)

2) The pie chart should display 3 slices (for the count of SMALL, MEDIUM, LARGE)

3) The label of each slice should contain one of the 3 SIZE-value and its number of occurence (SMALL 2, MEDIUM 2, LARGE 1)

 

However, when I create a report in iReport, I am inserting a pie chart and edit "Chart Data". I set "Reset Type" to "Report" and "Increment Type" to "None". The "Key Expression" is $F{SIZE}. The "Value Expression" is ${TOTAL}. The label expression is $F{SIZE} + "(" + $F{TOTAL} + ")".

The result is not quite satisfying: I get a report with 3 pages, each containing a pie chart. The first pie chart contains a single slice called MEDIUM (2). The second pie chart contains two slices called MEDIUM (2) and SMALL (2). Only the last page shows the pie chart I originally wanted to create. Three slices with number of occurence.

How do I restrict the result to only ONE pie chart containing ALL SIZEs and its occurence?

I hope you understand my problem and can help me.

Thank you in advance!

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

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