How to write a customizer class for bar chart, pie chart ?? (that should handle no data in subdataset & show proper No Data message) How to upload it to ireport ?? Anyone, please give some clear explanation on it.. please
5 Answers:
Hi subashmy,
What you can do is to create a variable that depends on the value of $F{totalCt} and another one that depends on $F{totalMin}, the "Variable Expression" should be as follows:
$F{totalCt} == null ? Double.valueOf("0.0") : $F{totalCt} --> For $V{TotalCt} variable
$F{totalMin} == null ? Double.valueOf("0.0") : $F{totalMin} --> For $V{TotalMin} variable
This way, if the value of the fields is null you'll have 0.00 in the variable, and otherwise you'll have the same value you have in the field. The you should change the variable expression in orther to use variables instead of fields:
' Summary
Total # of calls: ' + new DecimalFormat("#,000").format($V{totalCt}) + '
Total minutes: ' + new DecimalFormat("#,000").format($V{totalMin})
Maybe there is an easier option but I think this should work for you.
Let us know if you solve your problem.
Hope this helps,
Aitor
Hi,
First of all you need to create a customize class. The following is an example of a Line Chart customizer:
Thanks augarte, it helps... I wil get back to you on this.. meanwhile can you tellme how to deal with the following type of error??
Source text : '<b> Summary </b><p> Total # of calls: ' + new DecimalFormat("#,000").format($F{totalCt}) + '<p> Total minutes: ' + new DecimalFormat("#,000").format($F{totalMin})
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : '<b> Summary </b><p> Total # of calls: ' + new DecimalFormat("#,000").format($F{totalCt}) + '<p> Total minutes: ' + new DecimalFormat("#,000").format($F{totalMin}) ...........
I couldn't figure out how to resolve this... I have a report & four datasets, in two of the datasets, the data is coming as blank... so how should I deal with that???
What is that exactly? Where are you adding the following expression?
' Summary Total # of calls: ' + new DecimalFormat("#,000").format($F{totalCt}) + ' Total minutes: ' + new DecimalFormat("#,000").format($F{totalMin})
Something is wrong here with this expression. If you check the DecimalFormat javadoc you will see that there is not any "format" function with one parameter:
http://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html
So you have at least one error in this expression. Anyway, it would be easier to help you if you explain what do you want to do. From the expression I guess you need to add some data using "HTML markup" but don't know exactly what you want.
Regards,
Aitor
Total # of calls: ' + new DecimalFormat("#,000").format($F{totalCt}) + '
Total minutes: ' + new DecimalFormat("#,000").format($F{totalMin})
This one worked for me..
($V{member_id_MEASURE1} != 0 ? (new DecimalFormat(".00").format(($V{member_id_MEASURE1}/$V{member_id_MEASURE1_deny_reasons1_ALL}) * 100)) : 0 ) + "%"
I added the new DecimalFormat(".00").format( calculations) the + "%" is to give it like a percent look.
Hey Aitor, I have integer for both fields, so I am using the following expression..
$F{totalCt} == null ? 0 : $F{totalCt} for variable $V{TotalCt} & similarly other expression also..but still
Error evaluating expression....
Hi,
This works with Integer type field/variable:
$F{totalCt} == null ? Integer.valueOf("0") : $F{totalCt}