Variable as Pie chart value data

0

Hi

 

I am trying to put variable as value of pie chart series. Unfortunelly, I don't know how to do that, even though example of pie chart suggests its possible.

 

My problem is following:

I extract from database some records, which includes column "Type". I would like to make a pie chart with this types as a key and without adding extra Count() columns to my query. Is that possible?

E.G.

name                   type

me                       TYPE1

me2                     TYPE2

me                        TYPE1

then I would get pie chart with 1/3 labeled by TYPE2 and rest labeled with TYPE1

 I am using jasperreports 3.5.3 (the newest as far).

I am looking for solution, ideas or any clues, which can help me to find solution

Pawel



Post Edited by pawel_r at 08/24/2009 21:35
pawel_r's picture
45
Joined: Aug 20 2009 - 6:50am
Last seen: 4 years 11 months ago

6 Answers:

0

You'll have to:

  • Order the query by type.
  • Create a report group TypeGroup on the type field.
  • Set incrementType="Group" and incrementGroup="TypeGroup" for the chart, and use $V{TypeGroup_COUNT} as pie value.

HTH,

Lucian

lucianc's picture
5241
Joined: Jul 17 2006 - 1:10am
Last seen: 7 hours 25 min ago
0

Yes, it helped :)

Thanks a lot

pawel_r's picture
45
Joined: Aug 20 2009 - 6:50am
Last seen: 4 years 11 months ago
0

I have got another question related to the previous one. I would like to put two charts in single report and each of them would present the same data, but put in different categories (one for groups, one for system).

I added additional report group for system and put systemType_Count as value for chart, but it gives me wrong results (seems like it sums up each next category - I include picture).

Second question - I get ResultSet which contains some duplicated data (in sense that single id can be multiple times and I want to treat it as single instance in chart). I tried making reportGroup on id, but the result (group count) gives incorrect result. Am I missing sth?

 

pawel_r's picture
45
Joined: Aug 20 2009 - 6:50am
Last seen: 4 years 11 months ago
0

Keep in mind that the chart itself does not perform any sums/calculations, you need to sum the values using report variables.  So if the chart does not show the value that you expect, then you must be passing the wrong value to it.  Create a sum variable for the group that you want to sum, and make sure you set appropriate incrementType/Group for the chart.

The second thing to keep in mind is that grouping assumes that the data is already sorted by the same criteria.  So if you group by ID and want to have a single group per ID, you'll have to provide data sorted by ID.

Regards,

Lucian

lucianc's picture
5241
Joined: Jul 17 2006 - 1:10am
Last seen: 7 hours 25 min ago
0

Thanks a lot.

 

If I understood you correctly then I need another query for my report (or possibly a new subreport with chart), because I cannot order by two different fields (group and systems are not connected anyhow). As far as I know groups do not provide mechanism for sorting so I simply need another query (datasource).

Thanks again

pawel_r's picture
45
Joined: Aug 20 2009 - 6:50am
Last seen: 4 years 11 months ago
0

Right, you need two queries if you want to group by two unrelated fields.  You don't necessarily need subreports, you can use subdatasets as well.

Regards,

Lucian

lucianc's picture
5241
Joined: Jul 17 2006 - 1:10am
Last seen: 7 hours 25 min ago
Feedback
randomness