sgarciaf Posted June 14, 2010 Share Posted June 14, 2010 Hi,I have a query that only returns 0s and 1s. With this query I make a bar char with the 0s and 1s in the vertical axis. The category axis have words.I want to show in the vertical axis labels Yes and No instead of 1 and 0 (Yes=1 and No=0).I tried to put in the value expression:( $F{x}==0 ? "NO" : "YES" )but it didnt work. I think the value expression only allows number expressions. Anyone can help me? Link to comment Share on other sites More sharing options...
slow Posted June 14, 2010 Share Posted June 14, 2010 I don't use chart... but in the expression you set, if 0 and 1 are Integer values, then you must set:( $F{x}.intValue()==0 ? "NO" : "YES" )give feedback... Link to comment Share on other sites More sharing options...
sgarciaf Posted June 15, 2010 Author Share Posted June 15, 2010 It didnt work. This is the error I got:net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : ( $F{numEnt}.intValue()==0 ? "NO" : "SI" ) at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:710).......Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'NO' with class 'java.lang.String' to class 'java.lang.Integer' So the Vertical Axis is waiting for a Integer and I send a String.Is there a way to tell the Vertical Axis that Im gonna send a String? Link to comment Share on other sites More sharing options...
slow Posted June 15, 2010 Share Posted June 15, 2010 It seems that you use Groovy as language for you report...try to set it to Java... and verify what happens.uhm... maybe the chart supports only Integer values... Link to comment Share on other sites More sharing options...
sgarciaf Posted June 15, 2010 Author Share Posted June 15, 2010 with java gives a similar error. ouch I really need to put Yes and No in the vertical axis... any1 knows how to do this? Link to comment Share on other sites More sharing options...
slow Posted June 15, 2010 Share Posted June 15, 2010 I don't know what kind of chart you use in you report, but IReport uses JChart to create chart... so you can study it and customize the chart creation...try to take a look to it... maybe it can be useful Link to comment Share on other sites More sharing options...
sgarciaf Posted June 15, 2010 Author Share Posted June 15, 2010 I solved the problem manually...I inserted two StaticText elements above the chart, in the position of the 0 & 1 in the vertical axis. With the option Opaque selected, the StaticText hide the 0 & 1.Is not a really good solution, but i dont want to make a customizer class only for this case (& also I dont have time to check and study the JChart). EDIT: Thanks slow, you are always very useful. Karma for you!^^Post Edited by sgarciaf at 06/15/2010 13:00 Link to comment Share on other sites More sharing options...
slow Posted June 15, 2010 Share Posted June 15, 2010 a dirty solution... is also a solution :) 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