pawel_r Posted August 24, 2009 Share Posted August 24, 2009 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 typeme TYPE1me2 TYPE2me TYPE1then 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 solutionPawelPost Edited by pawel_r at 08/24/2009 21:35 Link to comment Share on other sites More sharing options...
lucianc Posted August 25, 2009 Share Posted August 25, 2009 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 Link to comment Share on other sites More sharing options...
pawel_r Posted August 26, 2009 Author Share Posted August 26, 2009 Yes, it helped :)Thanks a lot Link to comment Share on other sites More sharing options...
pawel_r Posted September 1, 2009 Author Share Posted September 1, 2009 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? Link to comment Share on other sites More sharing options...
lucianc Posted September 1, 2009 Share Posted September 1, 2009 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 Link to comment Share on other sites More sharing options...
pawel_r Posted September 1, 2009 Author Share Posted September 1, 2009 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 Link to comment Share on other sites More sharing options...
lucianc Posted September 1, 2009 Share Posted September 1, 2009 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now