leeyuiwah Posted December 14, 2008 Share Posted December 14, 2008 (This question can also be cast as "how to find the final total while walking through each row of a dataset")I want to plot a pie chart. In the label expression, I want to show thepercentage of each category in the overall total (i.e. the value of each key with respect to the overall total)So I wrote the Label Expression to beNumberFormat.getPercentInstance().format($F{num_incidents}.floatValue()/$V{totalNumIncident}.longValue())Here the $F{num_incidents} is the value of each row while$V{totalNumIncident} is my lame attempt to final the overall total$V{totalNumIncident} is calculated with the following settingsCalculation Type: SumReset Type: ReportIncrement Type: None Variable Expression: $F{num_incidents}Initial Value Expression: new Long(0)However, what I found is that the variable $V{totalNumIncident} was the *running total* at the time each row of the dataset was examined (i.e. when each category in the pie chart was plotted) but not the *final total*, so the precentages were all wrong.The final total (of all categories) can only be known when all rows havebeen walked through (all categories plotted), but when I plot each category, I need to know the final total. It looks like I need twopasses of walking through the data. But I don't know how to expressthat in iReport.Thanks!Clement Link to comment Share on other sites More sharing options...
teodord Posted December 16, 2008 Share Posted December 16, 2008 Hi,In JasperReports version 3.1.0, we have introduced two new properties to control the appearenace of section labels and legend labels. These two are called labelFormat and legendLabelFormat.You can use {0}, {1} and {2} for displaying the key, the value and the percentage in pie charts.For these formats to be used, you have to leave the labelExpression empty.I hope this helps.Teodor Link to comment Share on other sites More sharing options...
leeyuiwah Posted December 16, 2008 Author Share Posted December 16, 2008 Thanks! I guess I will have to upgrade then. Link to comment Share on other sites More sharing options...
mpgm Posted December 27, 2008 Share Posted December 27, 2008 how the labelFormat is used???can u explain with the example....what if i dont want to show the labels?? Link to comment Share on other sites More sharing options...
Gaby38 Posted December 28, 2008 Share Posted December 28, 2008 Teodord,Thanks for your advice. I am using the last releases of iReport (3.1.2) and Jasperserver (3.1.0) but I cannot see in Ireport the new properties you described. But it's true that by changing the "theme" property from nothing to "simple" I get a pie with labels containing both key and percentage, which is good for me.So my question is : what have I to do to access the new properties you spoke about. Am I obliged to use a "theme" definition?Thanks for your answer. Link to comment Share on other sites More sharing options...
leeyuiwah Posted January 2, 2009 Author Share Posted January 2, 2009 Teoder,Thanks for your answer. Now that after I upgrade to JS 3.1, I have the same question as Gaby38 and mpgm above. I could not an editable property called labelFormat or legendFormat.In fact, even if I save the JRXML file, there are no such string in the file.I do see that if I changed the theme from "nothing" to simple, then in the labels the percentages would be displayed. Unfortunately this is not good enough for me, because I am also asked to display the value.Thanks! Happy New Year!Clement Link to comment Share on other sites More sharing options...
teodord Posted January 16, 2009 Share Posted January 16, 2009 Hi,These two new settings for pie charts are available to all chart themes. You are not forced to use a particular chart theme to make use of them.However, the problem is that they are still missing from the iReport editor and we should log this as a bug.In the meantime, the only way to get around this is to edit them manually in the JRXML.Check the pie chart samples in the /demo/samplescharts folder of the JR project package. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
Gaby38 Posted January 22, 2009 Share Posted January 22, 2009 Thanks ,teodord,I edited the jrxml and put in place the new properties and it worked fine.But I have another question : is there a property to change the police used to display the above informations ? Link to comment Share on other sites More sharing options...
mdahlman Posted January 23, 2009 Share Posted January 23, 2009 Gaby38, Sorry, there is no simple way to set the font. You can set the legend font, but not the label font. To set the label font you would need to make a change to the chart customizer to expose this property. I've had this request before. It would be great if you could log this as an enhancement request. Regards,Matt Link to comment Share on other sites More sharing options...
pentaho Posted February 17, 2009 Share Posted February 17, 2009 Hi,How to display the fractional values in Pie chart...........<pie3DPlot labelFormat="{0} {2}" legendLabelFormat="{0} {1}"> <plot/> </pie3DPlotUsing this i can display only decimal values.....Like 20% 55%..........I want to display output in pie chart like 12.25%, 55.30%, 0.05%.........How can implement this..............Post Edited by pentaho pentaho at 02/17/09 13:08 Link to comment Share on other sites More sharing options...
mjvinoth Posted July 7, 2009 Share Posted July 7, 2009 Did you solve the problem ? please give me how to do like this pie chart. Thank you . Link to comment Share on other sites More sharing options...
mjvinoth Posted July 7, 2009 Share Posted July 7, 2009 pentahoWrote: Hi, How to display the fractional values in Pie chart........... <pie3DPlot labelFormat="{0} {2}" legendLabelFormat="{0} {1}"> <plot/> </pie3DPlot Using this i can display only decimal values..... Like 20% 55%.......... I want to display output in pie chart like 12.25%, 55.30%, 0.05%......... How can implement this.............. Post Edited by pentaho pentaho at 02/17/09 13:08 Please give me your ideas for create aboue pie chart. Link to comment Share on other sites More sharing options...
ppinnau Posted October 20, 2011 Share Posted October 20, 2011 I use {2} in a pie chart to display the percentage. However 2 problems remain:1. format decimal presicion (i need 2 fraction digits)2. Exclude "0 %" values. Zeroes come from my datasource and shell be present in a crosstab above the chart but not in the chart itself. A subreport would be a workaround.I can implement 1+2 in JasperReports. Question about that:- is there an interest to have this features in the official project?- if yes, a discussion of the XML-design for configuration is needed. 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