Jump to content

Vertical axis with Strings


sgarciaf

Recommended Posts

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

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...